From 5a64b3b86ca3e232c974da1c1006d3e78c8968e9 Mon Sep 17 00:00:00 2001 From: ggaren Date: Thu, 25 Oct 2007 22:29:55 +0000 Subject: [PATCH] Reviewed by Oliver Hunt. Rolled out my last patch. It turns out that I needed 2 words, not 1, so it didn't help. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27072 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- JavaScriptCore/ChangeLog | 7 ++ .../JavaScriptCore.xcodeproj/project.pbxproj | 1 - JavaScriptCore/kjs/Context.cpp | 2 +- JavaScriptCore/kjs/function.cpp | 44 ++++++------ JavaScriptCore/kjs/function.h | 68 ++----------------- 5 files changed, 37 insertions(+), 85 deletions(-) diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index 13d0d229d9c8..5d532f0ee6c2 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,10 @@ +2007-10-25 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Rolled out my last patch. It turns out that I needed 2 words, not 1, + so it didn't help. + 2007-10-25 Geoffrey Garen Reviewed by Oliver Hunt. diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index b96f8e17d7e8..abc796b52159 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -1379,7 +1379,6 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */; - compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; diff --git a/JavaScriptCore/kjs/Context.cpp b/JavaScriptCore/kjs/Context.cpp index 7d4779f0558e..e15b96a3609d 100644 --- a/JavaScriptCore/kjs/Context.cpp +++ b/JavaScriptCore/kjs/Context.cpp @@ -87,7 +87,7 @@ Context::~Context() // This prevents lists of Lists from building up, waiting to be garbage collected ActivationImp* activation = static_cast(m_activation); if (activation) - activation->resetArguments(); + activation->releaseArguments(); } void Context::mark() diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp index 25d06528a5ad..67ad38775fc7 100644 --- a/JavaScriptCore/kjs/function.cpp +++ b/JavaScriptCore/kjs/function.cpp @@ -390,34 +390,24 @@ bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName) // ------------------------------ ActivationImp -------------------------------- -void ActivationImp::LazyArgumentsObject::createArgumentsObject(ExecState* exec, ActivationImp* activationImp) -{ - setArgumentsObject(new Arguments(exec, function(), arguments, activationImp)); - - // The arguments list is only needed to create the arguments object, so - // discard it now. This prevents lists of Lists from building up, waiting - // to be garbage collected. - arguments.reset(); -} +const ClassInfo ActivationImp::info = {"Activation", 0, 0, 0}; -void ActivationImp::LazyArgumentsObject::mark() +// ECMA 10.1.6 +ActivationImp::ActivationImp(FunctionImp* function, const List& arguments) + : _function(function), _arguments(arguments), _argumentsObject(0) { - JSObject* o; - if (createdArgumentsObject()) - o = argumentsObject(); - else - o = function(); - - if (!o->marked()) - o->mark(); + // FIXME: Do we need to support enumerating the arguments property? } -const ClassInfo ActivationImp::info = {"Activation", 0, 0, 0}; - JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) { ActivationImp* thisObj = static_cast(slot.slotBase()); - return thisObj->m_lazyArgumentsObject.getOrCreate(exec, thisObj); + + // default: return builtin arguments array + if (!thisObj->_argumentsObject) + thisObj->createArgumentsObject(exec); + + return thisObj->_argumentsObject; } PropertySlot::GetValueFunc ActivationImp::getArgumentsGetter() @@ -462,10 +452,20 @@ void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* val void ActivationImp::mark() { - m_lazyArgumentsObject.mark(); + if (_function && !_function->marked()) + _function->mark(); + if (_argumentsObject && !_argumentsObject->marked()) + _argumentsObject->mark(); JSObject::mark(); } +void ActivationImp::createArgumentsObject(ExecState* exec) +{ + _argumentsObject = new Arguments(exec, _function, _arguments, const_cast(this)); + // The arguments list is only needed to create the arguments object, so discard it now + _arguments.reset(); +} + // ------------------------------ GlobalFunc ----------------------------------- diff --git a/JavaScriptCore/kjs/function.h b/JavaScriptCore/kjs/function.h index 12b5255ba3de..f104b3c4ea86 100644 --- a/JavaScriptCore/kjs/function.h +++ b/JavaScriptCore/kjs/function.h @@ -143,64 +143,7 @@ namespace KJS { class ActivationImp : public JSObject { public: - class LazyArgumentsObject { - public: - LazyArgumentsObject(FunctionImp* f, const List& a) - : arguments(a) - { - ASSERT(f); - setFunction(f); - } - - Arguments* getOrCreate(ExecState* exec, ActivationImp* activationImp) - { - if (!createdArgumentsObject()) - createArgumentsObject(exec, activationImp); - return argumentsObject(); - } - - void resetArguments() { arguments.reset(); } - void mark(); - - private: - static const uintptr_t TagMask = 1; // Pointer alignment leaves this bit open for tagging. - - void setArgumentsObject(Arguments* a) - { - u.argumentsObject = a; - u.bits |= TagMask; - } - - Arguments* argumentsObject() - { - ASSERT(createdArgumentsObject()); - return reinterpret_cast(u.bits & ~TagMask); - } - - void setFunction(FunctionImp* f) { u.function = f; } - FunctionImp* function() - { - ASSERT(!createdArgumentsObject()); - return u.function; - } - - bool createdArgumentsObject() { return (u.bits & TagMask) != 0; } - void createArgumentsObject(ExecState*, ActivationImp*); - - List arguments; - union { - // The low bit in this union is a flag: 0 means the union holds a - // FunctionImp*; 1 means the union holds an Arguments*. - uintptr_t bits; - FunctionImp* function; - Arguments* argumentsObject; - } u; - }; - - ActivationImp::ActivationImp(FunctionImp* function, const List& arguments) - : m_lazyArgumentsObject(function, arguments) - { - } + ActivationImp(FunctionImp* function, const List& arguments); virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None); @@ -213,13 +156,16 @@ namespace KJS { bool isActivation() { return true; } - void resetArguments() { m_lazyArgumentsObject.resetArguments(); } + void releaseArguments() { _arguments.reset(); } private: static PropertySlot::GetValueFunc getArgumentsGetter(); static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); - - LazyArgumentsObject m_lazyArgumentsObject; + void createArgumentsObject(ExecState*); + + FunctionImp* _function; + List _arguments; + mutable Arguments* _argumentsObject; }; class GlobalFuncImp : public InternalFunctionImp { -- 2.36.0