diff options
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp index dfe291c..1e9f670 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -47,6 +47,7 @@ #include "FunctionConstructor.h" #include "FunctionPrototype.h" #include "GlobalEvalFunction.h" +#include "JSFunction.h" #include "JSGlobalObjectFunctions.h" #include "JSLock.h" #include "Interpreter.h" @@ -78,10 +79,10 @@ static const int initialTickCountThreshold = 255; // Preferred number of milliseconds between each timeout check static const int preferredScriptCheckTimeInterval = 1000; -static inline void markIfNeeded(JSValuePtr v) +static inline void markIfNeeded(JSValue v) { - if (v && !v->marked()) - v->mark(); + if (v && !v.marked()) + v.mark(); } static inline void markIfNeeded(const RefPtr<Structure>& s) @@ -147,7 +148,7 @@ void JSGlobalObject::init(JSObject* thisValue) reset(prototype()); } -void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) +void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); @@ -156,20 +157,20 @@ void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValu JSVariableObject::put(exec, propertyName, value, slot); } -void JSGlobalObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValuePtr value, unsigned attributes) +void JSGlobalObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes) { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); if (symbolTablePutWithAttributes(propertyName, value, attributes)) return; - JSValuePtr valueBefore = getDirect(propertyName); + JSValue valueBefore = getDirect(propertyName); PutPropertySlot slot; JSVariableObject::put(exec, propertyName, value, slot); if (!valueBefore) { - JSValuePtr valueAfter = getDirect(propertyName); + JSValue valueAfter = getDirect(propertyName); if (valueAfter) - putDirect(propertyName, valueAfter, attributes); + JSObject::putWithAttributes(exec, propertyName, valueAfter, attributes); } } @@ -190,12 +191,12 @@ void JSGlobalObject::defineSetter(ExecState* exec, const Identifier& propertyNam static inline JSObject* lastInPrototypeChain(JSObject* object) { JSObject* o = object; - while (o->prototype()->isObject()) + while (o->prototype().isObject()) o = asObject(o->prototype()); return o; } -void JSGlobalObject::reset(JSValuePtr prototype) +void JSGlobalObject::reset(JSValue prototype) { ExecState* exec = JSGlobalObject::globalExec(); @@ -203,7 +204,11 @@ void JSGlobalObject::reset(JSValuePtr prototype) d()->functionPrototype = new (exec) FunctionPrototype(exec, FunctionPrototype::createStructure(jsNull())); // The real prototype will be set once ObjectPrototype is created. d()->prototypeFunctionStructure = PrototypeFunction::createStructure(d()->functionPrototype); - d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get()); + NativeFunctionWrapper* callFunction = 0; + NativeFunctionWrapper* applyFunction = 0; + d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction); + d()->callFunction = callFunction; + d()->applyFunction = applyFunction; d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get()); d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype); @@ -234,6 +239,8 @@ void JSGlobalObject::reset(JSValuePtr prototype) d()->regExpPrototype = new (exec) RegExpPrototype(exec, RegExpPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get()); d()->regExpStructure = RegExpObject::createStructure(d()->regExpPrototype); + d()->methodCallDummy = constructEmptyObject(exec); + ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, ErrorPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get()); d()->errorStructure = ErrorInstance::createStructure(errorPrototype); @@ -248,13 +255,13 @@ void JSGlobalObject::reset(JSValuePtr prototype) // Constructors - JSValuePtr objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype); - JSValuePtr functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype); - JSValuePtr arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype); - JSValuePtr stringConstructor = new (exec) StringConstructor(exec, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype); - JSValuePtr booleanConstructor = new (exec) BooleanConstructor(exec, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype); - JSValuePtr numberConstructor = new (exec) NumberConstructor(exec, NumberConstructor::createStructure(d()->functionPrototype), d()->numberPrototype); - JSValuePtr dateConstructor = new (exec) DateConstructor(exec, DateConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype); + JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype); + JSCell* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype); + JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype); + JSCell* stringConstructor = new (exec) StringConstructor(exec, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype); + JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype); + JSCell* numberConstructor = new (exec) NumberConstructor(exec, NumberConstructor::createStructure(d()->functionPrototype), d()->numberPrototype); + JSCell* dateConstructor = new (exec) DateConstructor(exec, DateConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype); d()->regExpConstructor = new (exec) RegExpConstructor(exec, RegExpConstructor::createStructure(d()->functionPrototype), d()->regExpPrototype); @@ -269,15 +276,15 @@ void JSGlobalObject::reset(JSValuePtr prototype) d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype); d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype); - d()->objectPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, objectConstructor, DontEnum); - d()->functionPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, functionConstructor, DontEnum); - d()->arrayPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, arrayConstructor, DontEnum); - d()->booleanPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, booleanConstructor, DontEnum); - d()->stringPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, stringConstructor, DontEnum); - d()->numberPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, numberConstructor, DontEnum); - d()->datePrototype->putDirectWithoutTransition(exec->propertyNames().constructor, dateConstructor, DontEnum); - d()->regExpPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum); - errorPrototype->putDirectWithoutTransition(exec->propertyNames().constructor, d()->errorConstructor, DontEnum); + d()->objectPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, objectConstructor, DontEnum); + d()->functionPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, functionConstructor, DontEnum); + d()->arrayPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, arrayConstructor, DontEnum); + d()->booleanPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, booleanConstructor, DontEnum); + d()->stringPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, stringConstructor, DontEnum); + d()->numberPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, numberConstructor, DontEnum); + d()->datePrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, dateConstructor, DontEnum); + d()->regExpPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum); + errorPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, d()->errorConstructor, DontEnum); evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum); rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum); @@ -290,21 +297,21 @@ void JSGlobalObject::reset(JSValuePtr prototype) // FIXME: These properties could be handled by a static hash table. - putDirectWithoutTransition(Identifier(exec, "Object"), objectConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "Function"), functionConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "Array"), arrayConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "Boolean"), booleanConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "String"), stringConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "Number"), numberConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "Date"), dateConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "RegExp"), d()->regExpConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "Error"), d()->errorConstructor, DontEnum); - putDirectWithoutTransition(Identifier(exec, "EvalError"), d()->evalErrorConstructor); - putDirectWithoutTransition(Identifier(exec, "RangeError"), d()->rangeErrorConstructor); - putDirectWithoutTransition(Identifier(exec, "ReferenceError"), d()->referenceErrorConstructor); - putDirectWithoutTransition(Identifier(exec, "SyntaxError"), d()->syntaxErrorConstructor); - putDirectWithoutTransition(Identifier(exec, "TypeError"), d()->typeErrorConstructor); - putDirectWithoutTransition(Identifier(exec, "URIError"), d()->URIErrorConstructor); + putDirectFunctionWithoutTransition(Identifier(exec, "Object"), objectConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "Function"), functionConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "Array"), arrayConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "Boolean"), booleanConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "String"), stringConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "Number"), numberConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "Date"), dateConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "RegExp"), d()->regExpConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "Error"), d()->errorConstructor, DontEnum); + putDirectFunctionWithoutTransition(Identifier(exec, "EvalError"), d()->evalErrorConstructor); + putDirectFunctionWithoutTransition(Identifier(exec, "RangeError"), d()->rangeErrorConstructor); + putDirectFunctionWithoutTransition(Identifier(exec, "ReferenceError"), d()->referenceErrorConstructor); + putDirectFunctionWithoutTransition(Identifier(exec, "SyntaxError"), d()->syntaxErrorConstructor); + putDirectFunctionWithoutTransition(Identifier(exec, "TypeError"), d()->typeErrorConstructor); + putDirectFunctionWithoutTransition(Identifier(exec, "URIError"), d()->URIErrorConstructor); // Set global values. GlobalPropertyInfo staticGlobals[] = { @@ -320,43 +327,32 @@ void JSGlobalObject::reset(JSValuePtr prototype) d()->evalFunction = new (exec) GlobalEvalFunction(exec, GlobalEvalFunction::createStructure(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this); putDirectFunctionWithoutTransition(exec, d()->evalFunction, DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum); - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum); #ifndef NDEBUG - putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum); + putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum); #endif resetPrototype(prototype); } // Set prototype, and also insert the object prototype at the end of the chain. -void JSGlobalObject::resetPrototype(JSValuePtr prototype) +void JSGlobalObject::resetPrototype(JSValue prototype) { setPrototype(prototype); - lastInPrototypeChain(this)->setPrototype(d()->objectPrototype); -} - -void JSGlobalObject::setTimeoutTime(unsigned timeoutTime) -{ - globalData()->interpreter->setTimeoutTime(timeoutTime); -} -void JSGlobalObject::startTimeoutCheck() -{ - globalData()->interpreter->startTimeoutCheck(); -} - -void JSGlobalObject::stopTimeoutCheck() -{ - globalData()->interpreter->stopTimeoutCheck(); + JSObject* oldLastInPrototypeChain = lastInPrototypeChain(this); + JSObject* objectPrototype = d()->objectPrototype; + if (oldLastInPrototypeChain != objectPrototype) + oldLastInPrototypeChain->setPrototype(objectPrototype); } void JSGlobalObject::mark() @@ -381,6 +377,8 @@ void JSGlobalObject::mark() markIfNeeded(d()->URIErrorConstructor); markIfNeeded(d()->evalFunction); + markIfNeeded(d()->callFunction); + markIfNeeded(d()->applyFunction); markIfNeeded(d()->objectPrototype); markIfNeeded(d()->functionPrototype); @@ -391,6 +389,8 @@ void JSGlobalObject::mark() markIfNeeded(d()->datePrototype); markIfNeeded(d()->regExpPrototype); + markIfNeeded(d()->methodCallDummy); + markIfNeeded(d()->errorStructure); // No need to mark the other structures, because their prototypes are all |