Changeset 28527 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Dec 7, 2007, 2:05:55 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Sam Weinig.

Next step in refactoring JSGlobalObject: Added JSVariableObject class,
and factored symbol-table-related code into it. (JSGlobalObject doesn't
use the symbol table code yet, though.)


Layout and JS tests, and testapi, pass. SunSpider reports no regression.

WebCore:

Reviewed by Sam Weinig.

Added some namespace qualifications and a forwarding header, now that
KJS::Node is sometimes #included in WebCore by JavaScriptCore headers.

  • ForwardingHeaders/wtf/ListRefPtr.h: Added.
  • bindings/js/JSXSLTProcessor.cpp: (KJS::JSXSLTProcessorPrototypeFunctionTransformToFragment::callAsFunction):
  • bindings/js/kjs_binding.cpp: (KJS::ScriptInterpreter::getDOMNodeForDocument): (KJS::ScriptInterpreter::forgetDOMNodeForDocument): (KJS::ScriptInterpreter::putDOMNodeForDocument): (KJS::ScriptInterpreter::markDOMNodesForDocument): (KJS::ScriptInterpreter::updateDOMNodeDocument):

WebKit/mac:

Reviewed by Sam Weinig.


Added a forwarding header, since we now #include nodes.h through some
JavaScriptCore headers.

  • ForwardingHeaders/wtf/ListRefPtr.h: Added.
Location:
trunk/JavaScriptCore/kjs
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r28468 r28527  
    5151    if (type == FunctionCode) {
    5252        m_activation = new ActivationImp(this);
    53         m_variable = m_activation;
     53        m_variableObject = m_activation;
    5454    } else {
    5555        m_activation = 0;
    56         m_variable = globalObject;
     56        m_variableObject = globalObject;
    5757    }
    5858   
     
    6262        if (m_callingExec) {
    6363            m_scopeChain = m_callingExec->scopeChain();
    64             m_variable = m_callingExec->variableObject();
     64            m_variableObject = m_callingExec->variableObject();
    6565            m_thisVal = m_callingExec->thisValue();
    6666            break;
     
    7373        m_scopeChain = func->scope();
    7474        m_scopeChain.push(m_activation);
    75         m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3)
     75        m_variableObject = m_activation;
    7676        m_thisVal = thisV;
    7777        break;
     
    107107void ExecState::updateLocalStorage()
    108108{
    109     m_localStorageBuffer = static_cast<ActivationImp*>(m_activation)->localStorage().data();
     109    m_localStorageBuffer = m_activation->localStorage().data();
    110110}
    111111
  • trunk/JavaScriptCore/kjs/ExecState.h

    r28468 r28527  
    3939    };
    4040   
    41     class JSGlobalObject;
    42     class ScopeChain;
    43     class Interpreter;
     41    class ActivationImp;
     42    class FunctionBodyNode;
    4443    class FunctionImp;
    4544    class GlobalFuncImp;
    46     class FunctionBodyNode;
     45    class Interpreter;
     46    class JSGlobalObject;
     47    class JSVariableObject;
     48    class ScopeChain;
    4749    struct LocalStorageEntry;
    4850   
     
    7476        const ScopeChain& scopeChain() const { return m_scopeChain; }
    7577       
    76         JSObject* variableObject() const { return m_variable; }
    77         void setVariableObject(JSObject* v) { m_variable = v; }
     78        JSVariableObject* variableObject() const { return m_variableObject; }
     79        void setVariableObject(JSVariableObject* v) { m_variableObject = v; }
    7880       
    7981        JSObject* thisValue() const { return m_thisVal; }
     
    8183        ExecState* callingExecState() { return m_callingExec; }
    8284       
    83         JSObject* activationObject() { return m_activation; }
     85        ActivationImp* activationObject() { return m_activation; }
    8486        CodeType codeType() { return m_codeType; }
    8587        FunctionBodyNode* currentBody() { return m_currentBody; }
     
    129131        FunctionImp* m_function;
    130132        const List* m_arguments;
    131         JSObject* m_activation;
     133        ActivationImp* m_activation;
    132134        LocalStorageEntry* m_localStorageBuffer;
    133135
    134136        ScopeChain m_scopeChain;
    135         JSObject* m_variable;
     137        JSVariableObject* m_variableObject;
    136138        JSObject* m_thisVal;
    137139       
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r28479 r28527  
    9393    ASSERT(JSLock::currentThreadIsHoldingLock());
    9494
    95     if (d->debugger)
    96         d->debugger->detach(this);
    97 
    98     d->next->d->prev = d->prev;
    99     d->prev->d->next = d->next;
    100     s_head = d->next;
     95    if (d()->debugger)
     96        d()->debugger->detach(this);
     97
     98    d()->next->d()->prev = d()->prev;
     99    d()->prev->d()->next = d()->next;
     100    s_head = d()->next;
    101101    if (s_head == this)
    102102        s_head = 0;
     103   
     104    delete d();
    103105}
    104106
     
    107109    ASSERT(JSLock::currentThreadIsHoldingLock());
    108110
    109     d.reset(new JSGlobalObjectData(this));
    110 
    111111    if (s_head) {
    112         d->prev = s_head;
    113         d->next = s_head->d->next;
    114         s_head->d->next->d->prev = this;
    115         s_head->d->next = this;
     112        d()->prev = s_head;
     113        d()->next = s_head->d()->next;
     114        s_head->d()->next->d()->prev = this;
     115        s_head->d()->next = this;
    116116    } else
    117         s_head = d->next = d->prev = this;
    118 
    119     d->compatMode = NativeMode;
     117        s_head = d()->next = d()->prev = this;
     118
     119    d()->compatMode = NativeMode;
    120120
    121121    resetTimeoutCheck();
    122     d->timeoutTime = 0;
    123     d->timeoutCheckCount = 0;
    124 
    125     d->currentExec = 0;
    126     d->recursion = 0;
    127     d->debugger = 0;
     122    d()->timeoutTime = 0;
     123    d()->timeoutCheckCount = 0;
     124
     125    d()->currentExec = 0;
     126    d()->recursion = 0;
     127    d()->debugger = 0;
    128128   
    129129    reset(prototype());
     
    144144    // new objects below.
    145145
    146     ExecState* exec = &d->globalExec;
     146    ExecState* exec = &d()->globalExec;
    147147
    148148    // Prototypes
    149     d->functionPrototype = 0;
    150     d->objectPrototype = 0;
    151 
    152     d->arrayPrototype = 0;
    153     d->stringPrototype = 0;
    154     d->booleanPrototype = 0;
    155     d->numberPrototype = 0;
    156     d->datePrototype = 0;
    157     d->regExpPrototype = 0;
    158     d->errorPrototype = 0;
    159    
    160     d->evalErrorPrototype = 0;
    161     d->rangeErrorPrototype = 0;
    162     d->referenceErrorPrototype = 0;
    163     d->syntaxErrorPrototype = 0;
    164     d->typeErrorPrototype = 0;
    165     d->URIErrorPrototype = 0;
     149    d()->functionPrototype = 0;
     150    d()->objectPrototype = 0;
     151
     152    d()->arrayPrototype = 0;
     153    d()->stringPrototype = 0;
     154    d()->booleanPrototype = 0;
     155    d()->numberPrototype = 0;
     156    d()->datePrototype = 0;
     157    d()->regExpPrototype = 0;
     158    d()->errorPrototype = 0;
     159   
     160    d()->evalErrorPrototype = 0;
     161    d()->rangeErrorPrototype = 0;
     162    d()->referenceErrorPrototype = 0;
     163    d()->syntaxErrorPrototype = 0;
     164    d()->typeErrorPrototype = 0;
     165    d()->URIErrorPrototype = 0;
    166166
    167167    // Constructors
    168     d->objectConstructor = 0;
    169     d->functionConstructor = 0;
    170     d->arrayConstructor = 0;
    171     d->stringConstructor = 0;
    172     d->booleanConstructor = 0;
    173     d->numberConstructor = 0;
    174     d->dateConstructor = 0;
    175     d->regExpConstructor = 0;
    176     d->errorConstructor = 0;
    177    
    178     d->evalErrorConstructor = 0;
    179     d->rangeErrorConstructor = 0;
    180     d->referenceErrorConstructor = 0;
    181     d->syntaxErrorConstructor = 0;
    182     d->typeErrorConstructor = 0;
    183     d->URIErrorConstructor = 0;
     168    d()->objectConstructor = 0;
     169    d()->functionConstructor = 0;
     170    d()->arrayConstructor = 0;
     171    d()->stringConstructor = 0;
     172    d()->booleanConstructor = 0;
     173    d()->numberConstructor = 0;
     174    d()->dateConstructor = 0;
     175    d()->regExpConstructor = 0;
     176    d()->errorConstructor = 0;
     177   
     178    d()->evalErrorConstructor = 0;
     179    d()->rangeErrorConstructor = 0;
     180    d()->referenceErrorConstructor = 0;
     181    d()->syntaxErrorConstructor = 0;
     182    d()->typeErrorConstructor = 0;
     183    d()->URIErrorConstructor = 0;
    184184
    185185    // Prototypes
    186     d->functionPrototype = new FunctionPrototype(exec);
    187     d->objectPrototype = new ObjectPrototype(exec, d->functionPrototype);
    188     d->functionPrototype->setPrototype(d->objectPrototype);
    189 
    190     d->arrayPrototype = new ArrayPrototype(exec, d->objectPrototype);
    191     d->stringPrototype = new StringPrototype(exec, d->objectPrototype);
    192     d->booleanPrototype = new BooleanPrototype(exec, d->objectPrototype, d->functionPrototype);
    193     d->numberPrototype = new NumberPrototype(exec, d->objectPrototype, d->functionPrototype);
    194     d->datePrototype = new DatePrototype(exec, d->objectPrototype);
    195     d->regExpPrototype = new RegExpPrototype(exec, d->objectPrototype, d->functionPrototype);;
    196     d->errorPrototype = new ErrorPrototype(exec, d->objectPrototype, d->functionPrototype);
    197    
    198     d->evalErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, EvalError, "EvalError", "EvalError");
    199     d->rangeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, RangeError, "RangeError", "RangeError");
    200     d->referenceErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError");
    201     d->syntaxErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError");
    202     d->typeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, TypeError, "TypeError", "TypeError");
    203     d->URIErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, URIError, "URIError", "URIError");
     186    d()->functionPrototype = new FunctionPrototype(exec);
     187    d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype);
     188    d()->functionPrototype->setPrototype(d()->objectPrototype);
     189
     190    d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype);
     191    d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype);
     192    d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);
     193    d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);
     194    d()->datePrototype = new DatePrototype(exec, d()->objectPrototype);
     195    d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);;
     196    d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);
     197   
     198    d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, EvalError, "EvalError", "EvalError");
     199    d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, RangeError, "RangeError", "RangeError");
     200    d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError");
     201    d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError");
     202    d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, TypeError, "TypeError", "TypeError");
     203    d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, URIError, "URIError", "URIError");
    204204
    205205    // Constructors
    206     d->objectConstructor = new ObjectObjectImp(exec, d->objectPrototype, d->functionPrototype);
    207     d->functionConstructor = new FunctionObjectImp(exec, d->functionPrototype);
    208     d->arrayConstructor = new ArrayObjectImp(exec, d->functionPrototype, d->arrayPrototype);
    209     d->stringConstructor = new StringObjectImp(exec, d->functionPrototype, d->stringPrototype);
    210     d->booleanConstructor = new BooleanObjectImp(exec, d->functionPrototype, d->booleanPrototype);
    211     d->numberConstructor = new NumberObjectImp(exec, d->functionPrototype, d->numberPrototype);
    212     d->dateConstructor = new DateObjectImp(exec, d->functionPrototype, d->datePrototype);
    213     d->regExpConstructor = new RegExpObjectImp(exec, d->functionPrototype, d->regExpPrototype);
    214     d->errorConstructor = new ErrorObjectImp(exec, d->functionPrototype, d->errorPrototype);
    215    
    216     d->evalErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->evalErrorPrototype);
    217     d->rangeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->rangeErrorPrototype);
    218     d->referenceErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->referenceErrorPrototype);
    219     d->syntaxErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->syntaxErrorPrototype);
    220     d->typeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->typeErrorPrototype);
    221     d->URIErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->URIErrorPrototype);
    222    
    223     d->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum);
    224 
    225     d->objectPrototype->put(exec, exec->propertyNames().constructor, d->objectConstructor, DontEnum | DontDelete | ReadOnly);
    226     d->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum | DontDelete | ReadOnly);
    227     d->arrayPrototype->put(exec, exec->propertyNames().constructor, d->arrayConstructor, DontEnum | DontDelete | ReadOnly);
    228     d->booleanPrototype->put(exec, exec->propertyNames().constructor, d->booleanConstructor, DontEnum | DontDelete | ReadOnly);
    229     d->stringPrototype->put(exec, exec->propertyNames().constructor, d->stringConstructor, DontEnum | DontDelete | ReadOnly);
    230     d->numberPrototype->put(exec, exec->propertyNames().constructor, d->numberConstructor, DontEnum | DontDelete | ReadOnly);
    231     d->datePrototype->put(exec, exec->propertyNames().constructor, d->dateConstructor, DontEnum | DontDelete | ReadOnly);
    232     d->regExpPrototype->put(exec, exec->propertyNames().constructor, d->regExpConstructor, DontEnum | DontDelete | ReadOnly);
    233     d->errorPrototype->put(exec, exec->propertyNames().constructor, d->errorConstructor, DontEnum | DontDelete | ReadOnly);
    234     d->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
    235     d->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
    236     d->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
    237     d->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
    238     d->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
    239     d->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
     206    d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype);
     207    d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype);
     208    d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype);
     209    d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype);
     210    d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype);
     211    d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype);
     212    d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype);
     213    d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype);
     214    d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype);
     215   
     216    d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype);
     217    d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype);
     218    d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype);
     219    d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype);
     220    d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype);
     221    d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype);
     222   
     223    d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
     224
     225    d()->objectPrototype->put(exec, exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly);
     226    d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly);
     227    d()->arrayPrototype->put(exec, exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly);
     228    d()->booleanPrototype->put(exec, exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly);
     229    d()->stringPrototype->put(exec, exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly);
     230    d()->numberPrototype->put(exec, exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly);
     231    d()->datePrototype->put(exec, exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly);
     232    d()->regExpPrototype->put(exec, exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly);
     233    d()->errorPrototype->put(exec, exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly);
     234    d()->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
     235    d()->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
     236    d()->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
     237    d()->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
     238    d()->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
     239    d()->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
    240240
    241241    // Set global constructors
     
    247247    // FIXME: These properties should be handled by a static hash table.
    248248
    249     putDirect("Object", d->objectConstructor, DontEnum);
    250     putDirect("Function", d->functionConstructor, DontEnum);
    251     putDirect("Array", d->arrayConstructor, DontEnum);
    252     putDirect("Boolean", d->booleanConstructor, DontEnum);
    253     putDirect("String", d->stringConstructor, DontEnum);
    254     putDirect("Number", d->numberConstructor, DontEnum);
    255     putDirect("Date", d->dateConstructor, DontEnum);
    256     putDirect("RegExp", d->regExpConstructor, DontEnum);
    257     putDirect("Error", d->errorConstructor, DontEnum);
    258     putDirect("EvalError", d->evalErrorConstructor, Internal);
    259     putDirect("RangeError", d->rangeErrorConstructor, Internal);
    260     putDirect("ReferenceError", d->referenceErrorConstructor, Internal);
    261     putDirect("SyntaxError", d->syntaxErrorConstructor, Internal);
    262     putDirect("TypeError", d->typeErrorConstructor, Internal);
    263     putDirect("URIError", d->URIErrorConstructor, Internal);
     249    putDirect("Object", d()->objectConstructor, DontEnum);
     250    putDirect("Function", d()->functionConstructor, DontEnum);
     251    putDirect("Array", d()->arrayConstructor, DontEnum);
     252    putDirect("Boolean", d()->booleanConstructor, DontEnum);
     253    putDirect("String", d()->stringConstructor, DontEnum);
     254    putDirect("Number", d()->numberConstructor, DontEnum);
     255    putDirect("Date", d()->dateConstructor, DontEnum);
     256    putDirect("RegExp", d()->regExpConstructor, DontEnum);
     257    putDirect("Error", d()->errorConstructor, DontEnum);
     258    putDirect("EvalError", d()->evalErrorConstructor, Internal);
     259    putDirect("RangeError", d()->rangeErrorConstructor, Internal);
     260    putDirect("ReferenceError", d()->referenceErrorConstructor, Internal);
     261    putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal);
     262    putDirect("TypeError", d()->typeErrorConstructor, Internal);
     263    putDirect("URIError", d()->URIErrorConstructor, Internal);
    264264
    265265    // Set global values.
    266266
    267     putDirect("Math", new MathObjectImp(exec, d->objectPrototype), DontEnum);
     267    putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum);
    268268
    269269    putDirect("NaN", jsNaN(), DontEnum | DontDelete);
     
    273273    // Set global functions.
    274274
    275     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
    276     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
    277     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
    278     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
    279     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
    280     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
    281     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
    282     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
    283     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
    284     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
    285     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
     275    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
     276    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
     277    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
     278    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
     279    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
     280    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
     281    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
     282    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
     283    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
     284    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
     285    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
    286286#ifndef NDEBUG
    287     putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
     287    putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
    288288#endif
    289289
     
    291291
    292292    setPrototype(prototype);
    293     lastInPrototypeChain(this)->setPrototype(d->objectPrototype);
     293    lastInPrototypeChain(this)->setPrototype(d()->objectPrototype);
    294294}
    295295
    296296void JSGlobalObject::startTimeoutCheck()
    297297{
    298     if (!d->timeoutCheckCount)
     298    if (!d()->timeoutCheckCount)
    299299        resetTimeoutCheck();
    300300   
    301     ++d->timeoutCheckCount;
     301    ++d()->timeoutCheckCount;
    302302}
    303303
    304304void JSGlobalObject::stopTimeoutCheck()
    305305{
    306     --d->timeoutCheckCount;
     306    --d()->timeoutCheckCount;
    307307}
    308308
    309309void JSGlobalObject::resetTimeoutCheck()
    310310{
    311     d->tickCount = 0;
    312     d->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
    313     d->timeAtLastCheckTimeout = 0;
    314     d->timeExecuting = 0;
     311    d()->tickCount = 0;
     312    d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
     313    d()->timeAtLastCheckTimeout = 0;
     314    d()->timeExecuting = 0;
    315315}
    316316
    317317bool JSGlobalObject::checkTimeout()
    318318{   
    319     d->tickCount = 0;
     319    d()->tickCount = 0;
    320320   
    321321    unsigned currentTime = getCurrentTime();
    322322
    323     if (!d->timeAtLastCheckTimeout) {
     323    if (!d()->timeAtLastCheckTimeout) {
    324324        // Suspicious amount of looping in a script -- start timing it
    325         d->timeAtLastCheckTimeout = currentTime;
     325        d()->timeAtLastCheckTimeout = currentTime;
    326326        return false;
    327327    }
    328328
    329     unsigned timeDiff = currentTime - d->timeAtLastCheckTimeout;
     329    unsigned timeDiff = currentTime - d()->timeAtLastCheckTimeout;
    330330
    331331    if (timeDiff == 0)
    332332        timeDiff = 1;
    333333   
    334     d->timeExecuting += timeDiff;
    335     d->timeAtLastCheckTimeout = currentTime;
     334    d()->timeExecuting += timeDiff;
     335    d()->timeAtLastCheckTimeout = currentTime;
    336336   
    337337    // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in
    338338    // preferredScriptCheckTimeInterval
    339     d->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d->ticksUntilNextTimeoutCheck;
     339    d()->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d()->ticksUntilNextTimeoutCheck;
    340340
    341341    // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the
    342342    // preferred script check time interval.
    343     if (d->ticksUntilNextTimeoutCheck == 0)
    344         d->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
    345 
    346     if (d->timeoutTime && d->timeExecuting > d->timeoutTime) {
     343    if (d()->ticksUntilNextTimeoutCheck == 0)
     344        d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
     345
     346    if (d()->timeoutTime && d()->timeExecuting > d()->timeoutTime) {
    347347        if (shouldInterruptScript())
    348348            return true;
     
    359359        builtins._internal = new SavedBuiltinsInternal;
    360360
    361     builtins._internal->objectConstructor = d->objectConstructor;
    362     builtins._internal->functionConstructor = d->functionConstructor;
    363     builtins._internal->arrayConstructor = d->arrayConstructor;
    364     builtins._internal->booleanConstructor = d->booleanConstructor;
    365     builtins._internal->stringConstructor = d->stringConstructor;
    366     builtins._internal->numberConstructor = d->numberConstructor;
    367     builtins._internal->dateConstructor = d->dateConstructor;
    368     builtins._internal->regExpConstructor = d->regExpConstructor;
    369     builtins._internal->errorConstructor = d->errorConstructor;
    370     builtins._internal->evalErrorConstructor = d->evalErrorConstructor;
    371     builtins._internal->rangeErrorConstructor = d->rangeErrorConstructor;
    372     builtins._internal->referenceErrorConstructor = d->referenceErrorConstructor;
    373     builtins._internal->syntaxErrorConstructor = d->syntaxErrorConstructor;
    374     builtins._internal->typeErrorConstructor = d->typeErrorConstructor;
    375     builtins._internal->URIErrorConstructor = d->URIErrorConstructor;
    376    
    377     builtins._internal->objectPrototype = d->objectPrototype;
    378     builtins._internal->functionPrototype = d->functionPrototype;
    379     builtins._internal->arrayPrototype = d->arrayPrototype;
    380     builtins._internal->booleanPrototype = d->booleanPrototype;
    381     builtins._internal->stringPrototype = d->stringPrototype;
    382     builtins._internal->numberPrototype = d->numberPrototype;
    383     builtins._internal->datePrototype = d->datePrototype;
    384     builtins._internal->regExpPrototype = d->regExpPrototype;
    385     builtins._internal->errorPrototype = d->errorPrototype;
    386     builtins._internal->evalErrorPrototype = d->evalErrorPrototype;
    387     builtins._internal->rangeErrorPrototype = d->rangeErrorPrototype;
    388     builtins._internal->referenceErrorPrototype = d->referenceErrorPrototype;
    389     builtins._internal->syntaxErrorPrototype = d->syntaxErrorPrototype;
    390     builtins._internal->typeErrorPrototype = d->typeErrorPrototype;
    391     builtins._internal->URIErrorPrototype = d->URIErrorPrototype;
     361    builtins._internal->objectConstructor = d()->objectConstructor;
     362    builtins._internal->functionConstructor = d()->functionConstructor;
     363    builtins._internal->arrayConstructor = d()->arrayConstructor;
     364    builtins._internal->booleanConstructor = d()->booleanConstructor;
     365    builtins._internal->stringConstructor = d()->stringConstructor;
     366    builtins._internal->numberConstructor = d()->numberConstructor;
     367    builtins._internal->dateConstructor = d()->dateConstructor;
     368    builtins._internal->regExpConstructor = d()->regExpConstructor;
     369    builtins._internal->errorConstructor = d()->errorConstructor;
     370    builtins._internal->evalErrorConstructor = d()->evalErrorConstructor;
     371    builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor;
     372    builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor;
     373    builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor;
     374    builtins._internal->typeErrorConstructor = d()->typeErrorConstructor;
     375    builtins._internal->URIErrorConstructor = d()->URIErrorConstructor;
     376   
     377    builtins._internal->objectPrototype = d()->objectPrototype;
     378    builtins._internal->functionPrototype = d()->functionPrototype;
     379    builtins._internal->arrayPrototype = d()->arrayPrototype;
     380    builtins._internal->booleanPrototype = d()->booleanPrototype;
     381    builtins._internal->stringPrototype = d()->stringPrototype;
     382    builtins._internal->numberPrototype = d()->numberPrototype;
     383    builtins._internal->datePrototype = d()->datePrototype;
     384    builtins._internal->regExpPrototype = d()->regExpPrototype;
     385    builtins._internal->errorPrototype = d()->errorPrototype;
     386    builtins._internal->evalErrorPrototype = d()->evalErrorPrototype;
     387    builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype;
     388    builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype;
     389    builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype;
     390    builtins._internal->typeErrorPrototype = d()->typeErrorPrototype;
     391    builtins._internal->URIErrorPrototype = d()->URIErrorPrototype;
    392392}
    393393
     
    397397        return;
    398398
    399     d->objectConstructor = builtins._internal->objectConstructor;
    400     d->functionConstructor = builtins._internal->functionConstructor;
    401     d->arrayConstructor = builtins._internal->arrayConstructor;
    402     d->booleanConstructor = builtins._internal->booleanConstructor;
    403     d->stringConstructor = builtins._internal->stringConstructor;
    404     d->numberConstructor = builtins._internal->numberConstructor;
    405     d->dateConstructor = builtins._internal->dateConstructor;
    406     d->regExpConstructor = builtins._internal->regExpConstructor;
    407     d->errorConstructor = builtins._internal->errorConstructor;
    408     d->evalErrorConstructor = builtins._internal->evalErrorConstructor;
    409     d->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;
    410     d->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;
    411     d->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;
    412     d->typeErrorConstructor = builtins._internal->typeErrorConstructor;
    413     d->URIErrorConstructor = builtins._internal->URIErrorConstructor;
    414 
    415     d->objectPrototype = builtins._internal->objectPrototype;
    416     d->functionPrototype = builtins._internal->functionPrototype;
    417     d->arrayPrototype = builtins._internal->arrayPrototype;
    418     d->booleanPrototype = builtins._internal->booleanPrototype;
    419     d->stringPrototype = builtins._internal->stringPrototype;
    420     d->numberPrototype = builtins._internal->numberPrototype;
    421     d->datePrototype = builtins._internal->datePrototype;
    422     d->regExpPrototype = builtins._internal->regExpPrototype;
    423     d->errorPrototype = builtins._internal->errorPrototype;
    424     d->evalErrorPrototype = builtins._internal->evalErrorPrototype;
    425     d->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;
    426     d->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;
    427     d->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;
    428     d->typeErrorPrototype = builtins._internal->typeErrorPrototype;
    429     d->URIErrorPrototype = builtins._internal->URIErrorPrototype;
     399    d()->objectConstructor = builtins._internal->objectConstructor;
     400    d()->functionConstructor = builtins._internal->functionConstructor;
     401    d()->arrayConstructor = builtins._internal->arrayConstructor;
     402    d()->booleanConstructor = builtins._internal->booleanConstructor;
     403    d()->stringConstructor = builtins._internal->stringConstructor;
     404    d()->numberConstructor = builtins._internal->numberConstructor;
     405    d()->dateConstructor = builtins._internal->dateConstructor;
     406    d()->regExpConstructor = builtins._internal->regExpConstructor;
     407    d()->errorConstructor = builtins._internal->errorConstructor;
     408    d()->evalErrorConstructor = builtins._internal->evalErrorConstructor;
     409    d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;
     410    d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;
     411    d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;
     412    d()->typeErrorConstructor = builtins._internal->typeErrorConstructor;
     413    d()->URIErrorConstructor = builtins._internal->URIErrorConstructor;
     414
     415    d()->objectPrototype = builtins._internal->objectPrototype;
     416    d()->functionPrototype = builtins._internal->functionPrototype;
     417    d()->arrayPrototype = builtins._internal->arrayPrototype;
     418    d()->booleanPrototype = builtins._internal->booleanPrototype;
     419    d()->stringPrototype = builtins._internal->stringPrototype;
     420    d()->numberPrototype = builtins._internal->numberPrototype;
     421    d()->datePrototype = builtins._internal->datePrototype;
     422    d()->regExpPrototype = builtins._internal->regExpPrototype;
     423    d()->errorPrototype = builtins._internal->errorPrototype;
     424    d()->evalErrorPrototype = builtins._internal->evalErrorPrototype;
     425    d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;
     426    d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;
     427    d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;
     428    d()->typeErrorPrototype = builtins._internal->typeErrorPrototype;
     429    d()->URIErrorPrototype = builtins._internal->URIErrorPrototype;
    430430}
    431431
    432432void JSGlobalObject::mark()
    433433{
    434     JSObject::mark();
    435 
    436     if (d->currentExec)
    437         d->currentExec->mark();
    438 
    439     markIfNeeded(d->globalExec.exception());
    440 
    441     markIfNeeded(d->objectConstructor);
    442     markIfNeeded(d->functionConstructor);
    443     markIfNeeded(d->arrayConstructor);
    444     markIfNeeded(d->booleanConstructor);
    445     markIfNeeded(d->stringConstructor);
    446     markIfNeeded(d->numberConstructor);
    447     markIfNeeded(d->dateConstructor);
    448     markIfNeeded(d->regExpConstructor);
    449     markIfNeeded(d->errorConstructor);
    450     markIfNeeded(d->evalErrorConstructor);
    451     markIfNeeded(d->rangeErrorConstructor);
    452     markIfNeeded(d->referenceErrorConstructor);
    453     markIfNeeded(d->syntaxErrorConstructor);
    454     markIfNeeded(d->typeErrorConstructor);
    455     markIfNeeded(d->URIErrorConstructor);
    456    
    457     markIfNeeded(d->objectPrototype);
    458     markIfNeeded(d->functionPrototype);
    459     markIfNeeded(d->arrayPrototype);
    460     markIfNeeded(d->booleanPrototype);
    461     markIfNeeded(d->stringPrototype);
    462     markIfNeeded(d->numberPrototype);
    463     markIfNeeded(d->datePrototype);
    464     markIfNeeded(d->regExpPrototype);
    465     markIfNeeded(d->errorPrototype);
    466     markIfNeeded(d->evalErrorPrototype);
    467     markIfNeeded(d->rangeErrorPrototype);
    468     markIfNeeded(d->referenceErrorPrototype);
    469     markIfNeeded(d->syntaxErrorPrototype);
    470     markIfNeeded(d->typeErrorPrototype);
    471     markIfNeeded(d->URIErrorPrototype);
     434    JSVariableObject::mark();
     435
     436    if (d()->currentExec)
     437        d()->currentExec->mark();
     438
     439    markIfNeeded(d()->globalExec.exception());
     440
     441    markIfNeeded(d()->objectConstructor);
     442    markIfNeeded(d()->functionConstructor);
     443    markIfNeeded(d()->arrayConstructor);
     444    markIfNeeded(d()->booleanConstructor);
     445    markIfNeeded(d()->stringConstructor);
     446    markIfNeeded(d()->numberConstructor);
     447    markIfNeeded(d()->dateConstructor);
     448    markIfNeeded(d()->regExpConstructor);
     449    markIfNeeded(d()->errorConstructor);
     450    markIfNeeded(d()->evalErrorConstructor);
     451    markIfNeeded(d()->rangeErrorConstructor);
     452    markIfNeeded(d()->referenceErrorConstructor);
     453    markIfNeeded(d()->syntaxErrorConstructor);
     454    markIfNeeded(d()->typeErrorConstructor);
     455    markIfNeeded(d()->URIErrorConstructor);
     456   
     457    markIfNeeded(d()->objectPrototype);
     458    markIfNeeded(d()->functionPrototype);
     459    markIfNeeded(d()->arrayPrototype);
     460    markIfNeeded(d()->booleanPrototype);
     461    markIfNeeded(d()->stringPrototype);
     462    markIfNeeded(d()->numberPrototype);
     463    markIfNeeded(d()->datePrototype);
     464    markIfNeeded(d()->regExpPrototype);
     465    markIfNeeded(d()->errorPrototype);
     466    markIfNeeded(d()->evalErrorPrototype);
     467    markIfNeeded(d()->rangeErrorPrototype);
     468    markIfNeeded(d()->referenceErrorPrototype);
     469    markIfNeeded(d()->syntaxErrorPrototype);
     470    markIfNeeded(d()->typeErrorPrototype);
     471    markIfNeeded(d()->URIErrorPrototype);
    472472}
    473473
    474474ExecState* JSGlobalObject::globalExec()
    475475{
    476     return &d->globalExec;
     476    return &d()->globalExec;
    477477}
    478478
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r28468 r28527  
    2424#define KJS_GlobalObject_h
    2525
    26 #include "object.h"
     26#include "JSVariableObject.h"
    2727
    2828namespace KJS {
     
    6868    enum CompatMode { NativeMode, IECompat, NetscapeCompat };
    6969
    70     class JSGlobalObject : public JSObject {
     70    class JSGlobalObject : public JSVariableObject {
    7171    protected:
    72         struct JSGlobalObjectData {
     72        using JSVariableObject::JSVariableObjectData;
     73
     74        struct JSGlobalObjectData : public JSVariableObjectData {
    7375            JSGlobalObjectData(JSGlobalObject* globalObject)
    74                 : globalExec(globalObject, globalObject, 0)
     76                : JSVariableObjectData(&inlineSymbolTable)
     77                , globalExec(globalObject, globalObject, 0)
    7578            {
    7679            }
     
    8184            Debugger* debugger;
    8285            CompatMode compatMode;
    83 
     86           
    8487            ExecState globalExec;
    8588            ExecState* currentExec;
     
    124127            NativeErrorPrototype* typeErrorPrototype;
    125128            NativeErrorPrototype* URIErrorPrototype;
     129
     130            SymbolTable inlineSymbolTable;
    126131        };
    127132
    128133    public:
    129134        JSGlobalObject()
     135            : JSVariableObject(new JSGlobalObjectData(this))
    130136        {
    131137            init();
     
    134140    protected:
    135141        JSGlobalObject(JSValue* proto)
    136             : JSObject(proto)
     142            : JSVariableObject(proto, new JSGlobalObjectData(this))
    137143        {
    138144            init();
     
    144150        // Linked list of all global objects.
    145151        static JSGlobalObject* head() { return s_head; }
    146         JSGlobalObject* next() { return d->next; }
     152        JSGlobalObject* next() { return d()->next; }
    147153
    148154        // Resets the global object to contain only built-in properties, sets
     
    155161        // replaces the global object's associated property.
    156162
    157         ObjectObjectImp* objectConstructor() const { return d->objectConstructor; }
    158         FunctionObjectImp* functionConstructor() const { return d->functionConstructor; }
    159         ArrayObjectImp* arrayConstructor() const { return d->arrayConstructor; }
    160         BooleanObjectImp* booleanConstructor() const { return d->booleanConstructor; }
    161         StringObjectImp* stringConstructor() const{ return d->stringConstructor; }
    162         NumberObjectImp* numberConstructor() const{ return d->numberConstructor; }
    163         DateObjectImp* dateConstructor() const{ return d->dateConstructor; }
    164         RegExpObjectImp* regExpConstructor() const { return d->regExpConstructor; }
    165         ErrorObjectImp* errorConstructor() const { return d->errorConstructor; }
    166         NativeErrorImp* evalErrorConstructor() const { return d->evalErrorConstructor; }
    167         NativeErrorImp* rangeErrorConstructor() const { return d->rangeErrorConstructor; }
    168         NativeErrorImp* referenceErrorConstructor() const { return d->referenceErrorConstructor; }
    169         NativeErrorImp* syntaxErrorConstructor() const { return d->syntaxErrorConstructor; }
    170         NativeErrorImp* typeErrorConstructor() const { return d->typeErrorConstructor; }
    171         NativeErrorImp* URIErrorConstructor() const { return d->URIErrorConstructor; }
    172 
    173         ObjectPrototype* objectPrototype() const { return d->objectPrototype; }
    174         FunctionPrototype* functionPrototype() const { return d->functionPrototype; }
    175         ArrayPrototype* arrayPrototype() const { return d->arrayPrototype; }
    176         BooleanPrototype* booleanPrototype() const { return d->booleanPrototype; }
    177         StringPrototype* stringPrototype() const { return d->stringPrototype; }
    178         NumberPrototype* numberPrototype() const { return d->numberPrototype; }
    179         DatePrototype* datePrototype() const { return d->datePrototype; }
    180         RegExpPrototype* regExpPrototype() const { return d->regExpPrototype; }
    181         ErrorPrototype* errorPrototype() const { return d->errorPrototype; }
    182         NativeErrorPrototype* evalErrorPrototype() const { return d->evalErrorPrototype; }
    183         NativeErrorPrototype* rangeErrorPrototype() const { return d->rangeErrorPrototype; }
    184         NativeErrorPrototype* referenceErrorPrototype() const { return d->referenceErrorPrototype; }
    185         NativeErrorPrototype* syntaxErrorPrototype() const { return d->syntaxErrorPrototype; }
    186         NativeErrorPrototype* typeErrorPrototype() const { return d->typeErrorPrototype; }
    187         NativeErrorPrototype* URIErrorPrototype() const { return d->URIErrorPrototype; }
     163        ObjectObjectImp* objectConstructor() const { return d()->objectConstructor; }
     164        FunctionObjectImp* functionConstructor() const { return d()->functionConstructor; }
     165        ArrayObjectImp* arrayConstructor() const { return d()->arrayConstructor; }
     166        BooleanObjectImp* booleanConstructor() const { return d()->booleanConstructor; }
     167        StringObjectImp* stringConstructor() const{ return d()->stringConstructor; }
     168        NumberObjectImp* numberConstructor() const{ return d()->numberConstructor; }
     169        DateObjectImp* dateConstructor() const{ return d()->dateConstructor; }
     170        RegExpObjectImp* regExpConstructor() const { return d()->regExpConstructor; }
     171        ErrorObjectImp* errorConstructor() const { return d()->errorConstructor; }
     172        NativeErrorImp* evalErrorConstructor() const { return d()->evalErrorConstructor; }
     173        NativeErrorImp* rangeErrorConstructor() const { return d()->rangeErrorConstructor; }
     174        NativeErrorImp* referenceErrorConstructor() const { return d()->referenceErrorConstructor; }
     175        NativeErrorImp* syntaxErrorConstructor() const { return d()->syntaxErrorConstructor; }
     176        NativeErrorImp* typeErrorConstructor() const { return d()->typeErrorConstructor; }
     177        NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; }
     178
     179        ObjectPrototype* objectPrototype() const { return d()->objectPrototype; }
     180        FunctionPrototype* functionPrototype() const { return d()->functionPrototype; }
     181        ArrayPrototype* arrayPrototype() const { return d()->arrayPrototype; }
     182        BooleanPrototype* booleanPrototype() const { return d()->booleanPrototype; }
     183        StringPrototype* stringPrototype() const { return d()->stringPrototype; }
     184        NumberPrototype* numberPrototype() const { return d()->numberPrototype; }
     185        DatePrototype* datePrototype() const { return d()->datePrototype; }
     186        RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; }
     187        ErrorPrototype* errorPrototype() const { return d()->errorPrototype; }
     188        NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; }
     189        NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; }
     190        NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; }
     191        NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; }
     192        NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; }
     193        NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; }
    188194
    189195        void saveBuiltins(SavedBuiltins&) const;
    190196        void restoreBuiltins(const SavedBuiltins&);
    191197
    192         void setTimeoutTime(unsigned timeoutTime) { d->timeoutTime = timeoutTime; }
     198        void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; }
    193199        void startTimeoutCheck();
    194200        void stopTimeoutCheck();
    195201        bool timedOut();
    196202
    197         Debugger* debugger() const { return d->debugger; }
    198         void setDebugger(Debugger* debugger) { d->debugger = debugger; }
    199 
    200         void setCurrentExec(ExecState* exec) { d->currentExec = exec; }
    201         ExecState* currentExec() const { return d->currentExec; }
     203        Debugger* debugger() const { return d()->debugger; }
     204        void setDebugger(Debugger* debugger) { d()->debugger = debugger; }
     205
     206        void setCurrentExec(ExecState* exec) { d()->currentExec = exec; }
     207        ExecState* currentExec() const { return d()->currentExec; }
    202208
    203209        // FIXME: Let's just pick one compatible behavior and go with it.
    204         void setCompatMode(CompatMode mode) { d->compatMode = mode; }
    205         CompatMode compatMode() const { return d->compatMode; }
     210        void setCompatMode(CompatMode mode) { d()->compatMode = mode; }
     211        CompatMode compatMode() const { return d()->compatMode; }
    206212       
    207         int recursion() { return d->recursion; }
    208         void incRecursion() { ++d->recursion; }
    209         void decRecursion() { --d->recursion; }
     213        int recursion() { return d()->recursion; }
     214        void incRecursion() { ++d()->recursion; }
     215        void decRecursion() { --d()->recursion; }
    210216
    211217        virtual void mark();
     
    218224
    219225        virtual bool isSafeScript(const JSGlobalObject*) const { return true; }
    220 
    221     protected:
    222         std::auto_ptr<JSGlobalObjectData> d;
    223226
    224227    private:
    225228        void init();
     229       
     230        JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
    226231
    227232        bool checkTimeout();
     
    233238    inline bool JSGlobalObject::timedOut()
    234239    {
    235         d->tickCount++;
    236 
    237         if (d->tickCount != d->ticksUntilNextTimeoutCheck)
     240        d()->tickCount++;
     241
     242        if (d()->tickCount != d()->ticksUntilNextTimeoutCheck)
    238243            return false;
    239244
  • trunk/JavaScriptCore/kjs/function.cpp

    r28468 r28527  
    9797  while (e) {
    9898    if (e->function() == thisObj)
    99       return static_cast<ActivationImp*>(e->activationObject())->get(exec, propertyName);
     99      return e->activationObject()->get(exec, propertyName);
    100100    e = e->callingExecState();
    101101  }
     
    359359const ClassInfo ActivationImp::info = { "Activation", 0, 0 };
    360360
    361 ActivationImp::ActivationImp(ExecState* exec)
    362     : d(new ActivationImpPrivate(exec))
    363     , m_symbolTable(&exec->function()->body->symbolTable())
    364 {
    365 }
    366 
    367361JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
    368362{
    369363  ActivationImp* thisObj = static_cast<ActivationImp*>(slot.slotBase());
    370   ActivationImpPrivate* d = thisObj->d.get();
    371  
    372   if (!d->argumentsObject)
     364 
     365  if (!thisObj->d()->argumentsObject)
    373366    thisObj->createArgumentsObject(exec);
    374367 
    375   return d->argumentsObject;
     368  return thisObj->d()->argumentsObject;
    376369}
    377370
     
    383376bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    384377{
    385     // We don't call through to JSObject because there's no way to give an
    386     // activation object getter/setter properties, and __proto__ is a
    387     // non-standard extension that other implementations do not expose in the
    388     // activation object.
    389     ASSERT(!_prop.hasGetterSetterProperties());
    390 
    391     // it's more efficient to just get and check for a special empty
    392     // value than to do a separate contains check
    393     size_t index = m_symbolTable->get(propertyName.ustring().rep());
    394     if (index != missingSymbolMarker()) {
    395         slot.setValueSlot(this, &d->localStorage[index].value);
     378    if (symbolTableGet(propertyName, slot))
    396379        return true;
    397     }
    398380
    399381    if (JSValue** location = getDirectLocation(propertyName)) {
     
    408390    }
    409391
     392    // We don't call through to JSObject because there's no way to give an
     393    // activation object getter properties or a prototype.
     394    ASSERT(!_prop.hasGetterSetterProperties());
     395    ASSERT(prototype() == jsNull());
    410396    return false;
    411397}
     
    416402        return false;
    417403
    418     if (m_symbolTable->contains(propertyName.ustring().rep()))
    419         return false;
    420 
    421     return JSObject::deleteProperty(exec, propertyName);
    422 }
    423 
    424 void ActivationImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    425 {
    426     SymbolTable::const_iterator::Keys end = m_symbolTable->end().keys();
    427     for (SymbolTable::const_iterator::Keys it = m_symbolTable->begin().keys(); it != end; ++it)
    428         propertyNames.add(Identifier(*it));
    429 
    430     JSObject::getPropertyNames(exec, propertyNames);
     404    return JSVariableObject::deleteProperty(exec, propertyName);
    431405}
    432406
    433407void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr)
    434408{
    435   // There's no way that an activation object can have a prototype or getter/setter properties.
    436   ASSERT(!_prop.hasGetterSetterProperties());
    437   ASSERT(prototype() == jsNull());
    438 
    439   // it's more efficient to just get and check for a special empty
    440   // value than to do a separate contains check
    441   size_t index = m_symbolTable->get(propertyName.ustring().rep());
    442   if (index != missingSymbolMarker()) {
    443     LocalStorageEntry& entry = d->localStorage[index];
    444     entry.value = value;
    445     entry.attributes = attr;
    446     return;
    447   }
    448 
    449   _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete));
     409    if (symbolTablePut(propertyName, value, attr))
     410        return;
     411
     412    // We don't call through to JSObject because __proto__ and getter/setter
     413    // properties are non-standard extensions that other implementations do not
     414    // expose in the activation object.
     415    ASSERT(!_prop.hasGetterSetterProperties());
     416    _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete));
    450417}
    451418
    452419void ActivationImp::mark()
    453420{
    454     JSObject::mark();
    455 
    456     size_t size = d->localStorage.size();
    457     for (size_t i = 0; i < size; ++i) {
    458         JSValue* value = d->localStorage[i].value;
    459         if (!value->marked())
    460             value->mark();
    461     }
    462    
    463     ASSERT(d->function);
    464     if (!d->function->marked())
    465         d->function->mark();
    466 
    467     if (d->argumentsObject && !d->argumentsObject->marked())
    468         d->argumentsObject->mark();
     421    JSVariableObject::mark();
     422
     423    if (d()->argumentsObject && !d()->argumentsObject->marked())
     424        d()->argumentsObject->mark();
    469425}
    470426
     
    474430    // we can retrieve our argument list from the ExecState for our function
    475431    // call instead of storing the list ourselves.
    476     d->argumentsObject = new Arguments(exec, d->function, *d->exec->arguments(), this);
     432    d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this);
    477433}
    478434
     
    764720        if (switchGlobal) {
    765721            newExec.pushScope(thisObj);
    766             newExec.setVariableObject(thisObj);
     722            newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj));
    767723        }
    768724       
  • trunk/JavaScriptCore/kjs/function.h

    r28110 r28527  
    2626#define KJS_FUNCTION_H
    2727
     28#include "JSVariableObject.h"
    2829#include "LocalStorage.h"
    2930#include "SymbolTable.h"
     31#include "nodes.h"
    3032#include "object.h"
    31 #include <wtf/OwnPtr.h>
    3233
    3334namespace KJS {
     
    138139  };
    139140
    140   class ActivationImp : public JSObject {
    141   private:
    142     struct ActivationImpPrivate {
    143         ActivationImpPrivate(ExecState* e)
    144             : exec(e)
    145             , function(e->function())
     141  class ActivationImp : public JSVariableObject {
     142  private:
     143    using JSVariableObject::JSVariableObjectData;
     144
     145    struct ActivationImpData : public JSVariableObjectData {
     146        ActivationImpData(ExecState* e)
     147            : JSVariableObjectData(&e->function()->body->symbolTable())
     148            , exec(e)
    146149            , argumentsObject(0)
    147150        {
    148151        }
    149        
    150         LocalStorage localStorage;
     152
    151153        ExecState* exec;
    152         FunctionImp* function;
    153154        Arguments* argumentsObject;
    154155    };
    155156
    156157  public:
    157     ActivationImp(ExecState*);
     158    ActivationImp::ActivationImp(ExecState* exec)
     159        : JSVariableObject(new ActivationImpData(exec))
     160    {
     161    }
     162
     163    virtual ~ActivationImp()
     164    {
     165        delete d();
     166    }
    158167
    159168    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    160169    virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None);
    161170    virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    162     virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    163171
    164172    virtual const ClassInfo* classInfo() const { return &info; }
     
    167175    virtual void mark();
    168176
    169     bool isActivation() { return true; }
    170 
    171     LocalStorage& localStorage() { return d->localStorage; }
    172     SymbolTable& symbolTable() { return *m_symbolTable; }
     177    virtual bool isActivationObject() { return true; }
    173178
    174179  private:
     
    176181    static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
    177182    void createArgumentsObject(ExecState*);
    178    
    179     OwnPtr<ActivationImpPrivate> d;
    180     SymbolTable* m_symbolTable;
     183    ActivationImpData* d() { return static_cast<ActivationImpData*>(JSVariableObject::d); }
    181184  };
    182185
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r28476 r28527  
    9494        return false;
    9595
    96     ASSERT(exec->variableObject()->isActivation()); // Because this is function code.
    97 
    9896    // Static lookup is impossible if the symbol isn't statically declared.
    99     if (!static_cast<ActivationImp*>(exec->variableObject())->symbolTable().contains(ident.ustring().rep()))
     97    if (!exec->variableObject()->symbolTable().contains(ident.ustring().rep()))
    10098        return false;
    10199       
     
    573571JSValue* LocalVarAccessNode::inlineEvaluate(ExecState* exec)
    574572{
    575     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    576     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     573    ASSERT(exec->variableObject() == exec->scopeChain().top());
    577574    return exec->localStorage()[index].value;
    578575}
     
    1001998      // of implementation we use the global object anyway here. This guarantees
    1002999      // that in host objects you always get a valid object for this.
    1003       if (thisObj->isActivation())
     1000      if (thisObj->isActivationObject())
    10041001        thisObj = exec->dynamicGlobalObject();
    10051002
     
    10471044JSValue* LocalVarFunctionCallNode::inlineEvaluate(ExecState* exec)
    10481045{
    1049     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1050     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1046    ASSERT(exec->variableObject() == exec->scopeChain().top());
    10511047
    10521048    JSValue* v = exec->localStorage()[index].value;
     
    11511147  ASSERT(thisObj);
    11521148  ASSERT(thisObj->isObject());
    1153   ASSERT(!thisObj->isActivation());
     1149  ASSERT(!thisObj->isActivationObject());
    11541150
    11551151  return func->call(exec, thisObj, argList);
     
    12001196  ASSERT(thisObj);
    12011197  ASSERT(thisObj->isObject());
    1202   ASSERT(!thisObj->isActivation());
     1198  ASSERT(!thisObj->isActivationObject());
    12031199
    12041200  return func->call(exec, thisObj, argList);
     
    12851281JSValue* PostIncLocalVarNode::evaluate(ExecState* exec)
    12861282{
    1287     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1288     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1283    ASSERT(exec->variableObject() == exec->scopeChain().top());
    12891284
    12901285    JSValue** slot = &exec->localStorage()[m_index].value;
     
    13431338JSValue* PostDecLocalVarNode::evaluate(ExecState* exec)
    13441339{
    1345     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1346     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1340    ASSERT(exec->variableObject() == exec->scopeChain().top());
    13471341
    13481342    JSValue** slot = &exec->localStorage()[m_index].value;
     
    13541348double PostDecLocalVarNode::inlineEvaluateToNumber(ExecState* exec)
    13551349{
    1356     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1357     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1350    ASSERT(exec->variableObject() == exec->scopeChain().top());
    13581351   
    13591352    JSValue** slot = &exec->localStorage()[m_index].value;
     
    16651658JSValue* LocalVarTypeOfNode::evaluate(ExecState* exec)
    16661659{
    1667     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1668     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1660    ASSERT(exec->variableObject() == exec->scopeChain().top());
    16691661
    16701662    return typeStringForValue(exec->localStorage()[m_index].value);
     
    17181710JSValue* PreIncLocalVarNode::evaluate(ExecState* exec)
    17191711{
    1720     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1721     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1712    ASSERT(exec->variableObject() == exec->scopeChain().top());
    17221713    JSValue** slot = &exec->localStorage()[m_index].value;
    17231714
     
    17661757JSValue* PreDecLocalVarNode::evaluate(ExecState* exec)
    17671758{
    1768     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    1769     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1759    ASSERT(exec->variableObject() == exec->scopeChain().top());
    17701760    JSValue** slot = &exec->localStorage()[m_index].value;
    17711761
     
    31793169JSValue* ReadModifyLocalVarNode::evaluate(ExecState* exec)
    31803170{
    3181     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    3182     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     3171    ASSERT(exec->variableObject() == exec->scopeChain().top());
    31833172    JSValue** slot = &exec->localStorage()[m_index].value;
    31843173
     
    31943183JSValue* AssignLocalVarNode::evaluate(ExecState* exec)
    31953184{
    3196     ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
    3197     ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     3185    ASSERT(exec->variableObject() == exec->scopeChain().top());
    31983186    JSValue* v = m_right->evaluate(exec);
    31993187
     
    45044492        optimizeVariableAccess();
    45054493
    4506     ASSERT(exec->variableObject()->isActivation());
    4507     LocalStorage& localStorage = static_cast<ActivationImp*>(exec->variableObject())->localStorage();
     4494    LocalStorage& localStorage = exec->variableObject()->localStorage();
    45084495    localStorage.reserveCapacity(m_varStack.size() + m_parameters.size() + m_functionStack.size());
    45094496   
  • trunk/JavaScriptCore/kjs/object.h

    r28468 r28527  
    454454    void restoreProperties(const SavedProperties &p) { _prop.restore(p); }
    455455
    456     virtual bool isActivation() { return false; }
     456    virtual bool isActivationObject() { return false; }
    457457    virtual bool isGlobalObject() const { return false; }
    458458  protected:
Note: See TracChangeset for help on using the changeset viewer.