Commit e25e04e3 authored by darin@apple.com's avatar darin@apple.com

JavaScriptCore:

        Reviewed by Anders.

        - http://bugs.webkit.org/show_bug.cgi?id=17067
          eliminate attributes parameter from JSObject::put for speed/clarity

        * API/JSCallbackObject.h: Removed attribute arguments.
        * API/JSCallbackObjectFunctions.h:
        (KJS::JSCallbackObject<Base>::put): Ditto.
        * API/JSObjectRef.cpp:
        (JSObjectSetProperty): Use initializeVariable or putDirect when necessary
        to set attribute values.
        * JavaScriptCore.exp: Updated.
        * bindings/objc/objc_runtime.h: Removed attribute arguments.
        * bindings/objc/objc_runtime.mm:
        (ObjcFallbackObjectImp::put): Ditto.
        * bindings/runtime_array.cpp:
        (RuntimeArray::put): Ditto.
        * bindings/runtime_array.h: Ditto.
        * bindings/runtime_object.cpp:
        (RuntimeObjectImp::put): Ditto.
        * bindings/runtime_object.h: Ditto. Also removed canPut which was only
        called from one place in WebCore that can use hasProperty instead.

        * kjs/Activation.h: Removed attribute argument from put and added the new
        initializeVariable function that's used to put variables in variable objects.
        Also made isActivationObject a const member.

        * kjs/JSGlobalObject.cpp:
        (KJS::JSGlobalObject::put): Removed attribute argument.
        (KJS::JSGlobalObject::initializeVariable): Added. Used to give variables
        their initial values, which can include the read-only property.
        (KJS::JSGlobalObject::reset): Removed obsolete comments about flags.
        Removed Internal flag, which is no longer needed.
        * kjs/JSGlobalObject.h: More of the same.

        * kjs/JSVariableObject.h: Added pure virtual initializeVariable function.
        (KJS::JSVariableObject::symbolTablePut): Removed checkReadOnly flag; we always
        check read-only.
        (KJS::JSVariableObject::symbolTableInitializeVariable): Added.

        * kjs/array_instance.cpp:
        (KJS::ArrayInstance::put): Removed attribute argument.
        * kjs/array_instance.h: Ditto.

        * kjs/function.cpp:
        (KJS::FunctionImp::put): Ditto.
        (KJS::Arguments::put): Ditto.
        (KJS::ActivationImp::put): Ditto.
        (KJS::ActivationImp::initializeVariable): Added.
        * kjs/function.h: Removed attribute arguments.

        * kjs/function_object.cpp:
        (KJS::FunctionObjectImp::construct): Removed Internal flag.

        * kjs/lookup.h:
        (KJS::lookupPut): Removed attributes argument. Also changed to use putDirect
        instead of calling JSObject::put.
        (KJS::cacheGlobalObject): Ditto.

        * kjs/nodes.cpp:
        (KJS::ConstDeclNode::handleSlowCase): Call initializeVariable to initialize
        the constant.
        (KJS::ConstDeclNode::evaluateSingle): Ditto.
        (KJS::TryNode::execute): Use putDirect to set up the new object.
        (KJS::FunctionBodyNode::processDeclarations): Removed Internal.
        (KJS::ProgramNode::processDeclarations): Ditto.
        (KJS::EvalNode::processDeclarations): Call initializeVariable to initialize
        the variables and functions.
        (KJS::FuncDeclNode::makeFunction): Removed Internal.
        (KJS::FuncExprNode::evaluate): Ditto.

        * kjs/object.cpp: Removed canPut, which was only being used in one code path,
        not the normal high speed one.
        (KJS::JSObject::put): Removed attribute argument. Moved the logic from
        canPut here, in the one code ath that was still using it.
        * kjs/object.h: Removed Internal attribute, ad canPut function. Removed the
        attributes argument to the put function. Made isActivationObject const.

        * kjs/regexp_object.cpp:
        (KJS::RegExpImp::put): Removed attributes argument.
        (KJS::RegExpImp::putValueProperty): Ditto.
        (KJS::RegExpObjectImp::put): Ditto.
        (KJS::RegExpObjectImp::putValueProperty): Ditto.
        * kjs/regexp_object.h: Ditto.

        * kjs/string_object.cpp:
        (KJS::StringInstance::put): Removed attributes argument.
        * kjs/string_object.h: Ditto.

WebCore:

        Reviewed by Anders.

        - http://bugs.webkit.org/show_bug.cgi?id=17067
          eliminate attributes parameter from JSObject::put for speed/clarity

        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
        (WebCore::JSCSSStyleDeclaration::customPut): Remove attributes argument.

        * bindings/js/JSCanvasPixelArrayCustom.cpp:
        (WebCore::JSCanvasPixelArray::indexGetter): Use early exit idiom.
        (WebCore::JSCanvasPixelArray::indexSetter): Moved length check into the
        CanvasPixelArray object, for consistency with the getter. Removed attributes
        argument.

        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::JSDOMWindow::customPut): Removed special case for variable
        initialization, which is not needed since that does use put any more.
        Removed attributes argument.

        * bindings/js/JSEventTargetBase.h:
        (WebCore::JSEventTargetBase::putValueProperty): Removed attributes argument.
        (WebCore::JSEventTargetBase::put): Ditto.
        (WebCore::JSEventTargetPrototype::self): Removed Internal flag.
        * bindings/js/JSEventTargetNode.cpp:
        (WebCore::JSEventTargetNode::put): Removed attributes argument.
        (WebCore::JSEventTargetNode::putValueProperty): Ditto.
        * bindings/js/JSEventTargetNode.h: Ditto.
        * bindings/js/JSHTMLAppletElementCustom.cpp:
        (WebCore::JSHTMLAppletElement::customPut): Ditto.
        * bindings/js/JSHTMLEmbedElementCustom.cpp:
        (WebCore::JSHTMLEmbedElement::customPut): Ditto.
        * bindings/js/JSHTMLInputElementBase.cpp:
        (WebCore::JSHTMLInputElementBase::put): Ditto.
        (WebCore::JSHTMLInputElementBase::putValueProperty): Ditto.
        * bindings/js/JSHTMLInputElementBase.h: Ditto.
        * bindings/js/JSHTMLObjectElementCustom.cpp:
        (WebCore::JSHTMLObjectElement::customPut): Ditto.
        * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
        (WebCore::JSHTMLOptionsCollection::indexSetter): Ditto.
        * bindings/js/JSHTMLSelectElementCustom.cpp:
        (WebCore::JSHTMLSelectElement::indexSetter): Ditto.
        * bindings/js/JSHistoryCustom.cpp:
        (WebCore::JSHistory::customPut): Ditto.
        * bindings/js/JSLocation.cpp:
        (WebCore::JSLocation::put): Ditto.
        * bindings/js/JSLocation.h: Ditto.
        * bindings/js/JSXMLHttpRequest.cpp:
        (WebCore::JSXMLHttpRequest::put): Ditto.
        (WebCore::JSXMLHttpRequest::putValueProperty): Ditto.
        * bindings/js/JSXMLHttpRequest.h: Ditto.

        * bindings/js/kjs_dom.cpp:
        (WebCore::getRuntimeObject): Changed return type to JSObject*.
        * bindings/js/kjs_dom.h: Ditto.

        * bindings/js/kjs_events.cpp:
        (WebCore::JSClipboard::put): Removed attributes argument.
        (WebCore::JSClipboard::putValueProperty): Ditto.
        * bindings/js/kjs_events.h: Ditto.

        * bindings/js/kjs_html.cpp:
        (WebCore::runtimeObjectGetter): Updated for change to getRuntimeObject to
        return a JSObject. Used early exit idiom.
        (WebCore::runtimeObjectPropertyGetter): Ditto.
        (WebCore::runtimeObjectCustomGetOwnPropertySlot): Ditto.
        (WebCore::runtimeObjectCustomPut): Use hasProperty to check for properties
        that we should put with the property syntax instead of canPut.
        (WebCore::runtimeObjectImplementsCall): Ditto.
        (WebCore::runtimeObjectCallAsFunction): Ditto.
        * bindings/js/kjs_html.h: Removed attributes argument to runtimeObjectCustomPut.

        * bindings/js/kjs_window.cpp:
        (KJS::Window::put): Removed attributes argument.
        * bindings/js/kjs_window.h: Ditto.

        * bindings/scripts/CodeGeneratorJS.pm: Removed attributes argument from put,
        putValueProperty, customPut, and indexSetter.

        * html/CanvasPixelArray.h:
        (WebCore::CanvasPixelArray::set): Added index checking here, as in the get
        function. Before, the checking was done in the JavaScript bindings for set.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9567d319
......@@ -47,8 +47,8 @@ public:
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned, PropertySlot&);
virtual void put(ExecState*, const Identifier&, JSValue*, int attr);
virtual void put(ExecState*, unsigned, JSValue*, int attr);
virtual void put(ExecState*, const Identifier&, JSValue*);
virtual void put(ExecState*, unsigned, JSValue*);
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual bool deleteProperty(ExecState*, unsigned);
......
......@@ -150,7 +150,7 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, unsigned proper
}
template <class Base>
void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
......@@ -181,19 +181,19 @@ void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
return;
JSCallbackObject<Base>::putDirect(propertyName, value, attr); // put as override property
JSCallbackObject<Base>::putDirect(propertyName, value); // put as override property
return;
}
}
}
return Base::put(exec, propertyName, value, attr);
return Base::put(exec, propertyName, value);
}
template <class Base>
void JSCallbackObject<Base>::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)
void JSCallbackObject<Base>::put(ExecState* exec, unsigned propertyName, JSValue* value)
{
return put(exec, Identifier::from(propertyName), value, attr);
return put(exec, Identifier::from(propertyName), value);
}
template <class Base>
......
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -27,15 +27,13 @@
#include "config.h"
#include "JSObjectRef.h"
#include <wtf/Platform.h>
#include "APICast.h"
#include "JSValueRef.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
#include "JSCallbackObject.h"
#include "JSClassRef.h"
#include "JSGlobalObject.h"
#include "JSValueRef.h"
#include "PropertyNameArray.h"
#include "function.h"
#include "function_object.h"
......@@ -43,6 +41,7 @@
#include "internal.h"
#include "object.h"
#include "object_object.h"
#include <wtf/Platform.h>
using namespace KJS;
......@@ -177,10 +176,21 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope
JSLock lock;
ExecState* exec = toJS(ctx);
JSObject* jsObject = toJS(object);
UString::Rep* nameRep = toJS(propertyName);
Identifier name(toJS(propertyName));
JSValue* jsValue = toJS(value);
jsObject->put(exec, Identifier(nameRep), jsValue, attributes);
// If non-0 attributes were passed, we may need to use a lower-level call than
// the normal JSObject::put. If there is no existing property, then use either
// initializeVariable or putDirect instead, since those have the power to set attributes.
if (attributes && !jsObject->hasProperty(exec, name)) {
if (jsObject->isGlobalObject())
static_cast<JSGlobalObject*>(jsObject)->initializeVariable(exec, name, jsValue, attributes);
else
jsObject->putDirect(name, jsValue, attributes);
return;
}
jsObject->put(exec, name, jsValue);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
......
2008-02-23 Darin Adler <darin@apple.com>
Reviewed by Anders.
- http://bugs.webkit.org/show_bug.cgi?id=17067
eliminate attributes parameter from JSObject::put for speed/clarity
* API/JSCallbackObject.h: Removed attribute arguments.
* API/JSCallbackObjectFunctions.h:
(KJS::JSCallbackObject<Base>::put): Ditto.
* API/JSObjectRef.cpp:
(JSObjectSetProperty): Use initializeVariable or putDirect when necessary
to set attribute values.
* JavaScriptCore.exp: Updated.
* bindings/objc/objc_runtime.h: Removed attribute arguments.
* bindings/objc/objc_runtime.mm:
(ObjcFallbackObjectImp::put): Ditto.
* bindings/runtime_array.cpp:
(RuntimeArray::put): Ditto.
* bindings/runtime_array.h: Ditto.
* bindings/runtime_object.cpp:
(RuntimeObjectImp::put): Ditto.
* bindings/runtime_object.h: Ditto. Also removed canPut which was only
called from one place in WebCore that can use hasProperty instead.
* kjs/Activation.h: Removed attribute argument from put and added the new
initializeVariable function that's used to put variables in variable objects.
Also made isActivationObject a const member.
* kjs/JSGlobalObject.cpp:
(KJS::JSGlobalObject::put): Removed attribute argument.
(KJS::JSGlobalObject::initializeVariable): Added. Used to give variables
their initial values, which can include the read-only property.
(KJS::JSGlobalObject::reset): Removed obsolete comments about flags.
Removed Internal flag, which is no longer needed.
* kjs/JSGlobalObject.h: More of the same.
* kjs/JSVariableObject.h: Added pure virtual initializeVariable function.
(KJS::JSVariableObject::symbolTablePut): Removed checkReadOnly flag; we always
check read-only.
(KJS::JSVariableObject::symbolTableInitializeVariable): Added.
* kjs/array_instance.cpp:
(KJS::ArrayInstance::put): Removed attribute argument.
* kjs/array_instance.h: Ditto.
* kjs/function.cpp:
(KJS::FunctionImp::put): Ditto.
(KJS::Arguments::put): Ditto.
(KJS::ActivationImp::put): Ditto.
(KJS::ActivationImp::initializeVariable): Added.
* kjs/function.h: Removed attribute arguments.
* kjs/function_object.cpp:
(KJS::FunctionObjectImp::construct): Removed Internal flag.
* kjs/lookup.h:
(KJS::lookupPut): Removed attributes argument. Also changed to use putDirect
instead of calling JSObject::put.
(KJS::cacheGlobalObject): Ditto.
* kjs/nodes.cpp:
(KJS::ConstDeclNode::handleSlowCase): Call initializeVariable to initialize
the constant.
(KJS::ConstDeclNode::evaluateSingle): Ditto.
(KJS::TryNode::execute): Use putDirect to set up the new object.
(KJS::FunctionBodyNode::processDeclarations): Removed Internal.
(KJS::ProgramNode::processDeclarations): Ditto.
(KJS::EvalNode::processDeclarations): Call initializeVariable to initialize
the variables and functions.
(KJS::FuncDeclNode::makeFunction): Removed Internal.
(KJS::FuncExprNode::evaluate): Ditto.
* kjs/object.cpp: Removed canPut, which was only being used in one code path,
not the normal high speed one.
(KJS::JSObject::put): Removed attribute argument. Moved the logic from
canPut here, in the one code ath that was still using it.
* kjs/object.h: Removed Internal attribute, ad canPut function. Removed the
attributes argument to the put function. Made isActivationObject const.
* kjs/regexp_object.cpp:
(KJS::RegExpImp::put): Removed attributes argument.
(KJS::RegExpImp::putValueProperty): Ditto.
(KJS::RegExpObjectImp::put): Ditto.
(KJS::RegExpObjectImp::putValueProperty): Ditto.
* kjs/regexp_object.h: Ditto.
* kjs/string_object.cpp:
(KJS::StringInstance::put): Removed attributes argument.
* kjs/string_object.h: Ditto.
2008-02-23 Jan Michael Alonzo <jmalonzo@unpluggable.com>
Not reviewed, Gtk build fix.
......
......@@ -136,7 +136,8 @@ __ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE
__ZN3KJS14JSGlobalObject16stopTimeoutCheckEv
__ZN3KJS14JSGlobalObject17startTimeoutCheckEv
__ZN3KJS14JSGlobalObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
__ZN3KJS14JSGlobalObject18initializeVariableEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEj
__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS14JSGlobalObject4initEv
__ZN3KJS14JSGlobalObject4markEv
__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
......@@ -146,7 +147,7 @@ __ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS14StringInstance4infoE
__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE
__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
......@@ -216,8 +217,8 @@ __ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3KJS8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE
__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE
__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueEi
__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueE
__ZN3KJS8JSObject4callEPNS_9ExecStateEPS0_RKNS_4ListE
__ZN3KJS8JSObject4markEv
__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListE
......@@ -280,7 +281,6 @@ __ZNK3KJS8JSObject21implementsHasInstanceEv
__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
__ZNK3KJS8JSObject3getEPNS_9ExecStateEj
__ZNK3KJS8JSObject4typeEv
__ZNK3KJS8JSObject6canPutEPNS_9ExecStateERKNS_10IdentifierE
__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE
__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE
__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE
......
......@@ -103,8 +103,7 @@ public:
const ClassInfo *classInfo() const { return &info; }
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
virtual bool implementsCall() const;
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
......
......@@ -211,16 +211,10 @@ bool ObjcFallbackObjectImp::getOwnPropertySlot(ExecState*, const Identifier&, Pr
return true;
}
void ObjcFallbackObjectImp::put(ExecState*, const Identifier&, JSValue*, int)
void ObjcFallbackObjectImp::put(ExecState*, const Identifier&, JSValue*)
{
}
bool ObjcFallbackObjectImp::canPut(ExecState*, const Identifier&) const
{
return false;
}
JSType ObjcFallbackObjectImp::type() const
{
id targetObject = _instance->getObject();
......
......@@ -80,7 +80,7 @@ bool RuntimeArray::getOwnPropertySlot(ExecState *exec, unsigned index, PropertyS
return JSObject::getOwnPropertySlot(exec, index, slot);
}
void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
if (propertyName == exec->propertyNames().length) {
throwError(exec, RangeError);
......@@ -94,10 +94,10 @@ void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue*
return;
}
JSObject::put(exec, propertyName, value, attr);
JSObject::put(exec, propertyName, value);
}
void RuntimeArray::put(ExecState* exec, unsigned index, JSValue* value, int)
void RuntimeArray::put(ExecState* exec, unsigned index, JSValue* value)
{
if (index >= getLength()) {
throwError(exec, RangeError);
......
......@@ -39,8 +39,8 @@ public:
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value);
virtual void put(ExecState *exec, unsigned propertyName, JSValue *value);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
......
......@@ -154,7 +154,7 @@ bool RuntimeObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& pro
return false;
}
void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int)
void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
if (!instance) {
throwInvalidAccessError(exec);
......@@ -174,22 +174,6 @@ void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSVa
instance->end();
}
bool RuntimeObjectImp::canPut(ExecState* exec, const Identifier& propertyName) const
{
if (!instance) {
throwInvalidAccessError(exec);
return false;
}
instance->begin();
Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get());
instance->end();
return !!aField;
}
bool RuntimeObjectImp::deleteProperty(ExecState*, const Identifier&)
{
// Can never remove a property of a RuntimeObject.
......
......@@ -40,8 +40,7 @@ public:
const ClassInfo *classInfo() const { return &info; }
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual JSValue *defaultValue(ExecState *exec, JSType hint) const;
virtual bool implementsCall() const;
......
......@@ -58,7 +58,8 @@ namespace KJS {
void init(ExecState*);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None);
virtual void put(ExecState*, const Identifier&, JSValue*);
virtual void initializeVariable(ExecState*, const Identifier&, JSValue*, unsigned attributes);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual const ClassInfo* classInfo() const { return &info; }
......@@ -67,7 +68,7 @@ namespace KJS {
virtual void mark();
void markChildren();
virtual bool isActivationObject() { return true; }
virtual bool isActivationObject() const { return true; }
bool isOnStack() const { return d()->isOnStack; }
bool needsPop() const { return d()->isOnStack || d()->leftRelic; }
......
......@@ -152,11 +152,24 @@ bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& prope
return JSVariableObject::getOwnPropertySlot(exec, propertyName, slot);
}
void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
if (symbolTablePut(propertyName, value, !(attr & ~DontDelete)))
if (symbolTablePut(propertyName, value))
return;
return JSVariableObject::put(exec, propertyName, value, attr);
return JSVariableObject::put(exec, propertyName, value);
}
void JSGlobalObject::initializeVariable(ExecState* exec, const Identifier& propertyName, JSValue* value, unsigned attributes)
{
if (symbolTableInitializeVariable(propertyName, value, attributes))
return;
JSValue* valueBefore = getDirect(propertyName);
JSVariableObject::put(exec, propertyName, value);
if (!valueBefore) {
if (JSValue* valueAfter = getDirect(propertyName))
putDirect(propertyName, valueAfter, attributes);
}
}
static inline JSObject* lastInPrototypeChain(JSObject* object)
......@@ -274,11 +287,7 @@ void JSGlobalObject::reset(JSValue* prototype)
// Set global constructors
// FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to
// see that these values can be put directly without a check for override
// properties.
// FIXME: These properties should be handled by a static hash table.
// FIXME: These properties could be handled by a static hash table.
putDirect("Object", d()->objectConstructor, DontEnum);
putDirect("Function", d()->functionConstructor, DontEnum);
......@@ -289,12 +298,12 @@ void JSGlobalObject::reset(JSValue* prototype)
putDirect("Date", d()->dateConstructor, DontEnum);
putDirect("RegExp", d()->regExpConstructor, DontEnum);
putDirect("Error", d()->errorConstructor, DontEnum);
putDirect("EvalError", d()->evalErrorConstructor, Internal);
putDirect("RangeError", d()->rangeErrorConstructor, Internal);
putDirect("ReferenceError", d()->referenceErrorConstructor, Internal);
putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal);
putDirect("TypeError", d()->typeErrorConstructor, Internal);
putDirect("URIError", d()->URIErrorConstructor, Internal);
putDirect("EvalError", d()->evalErrorConstructor);
putDirect("RangeError", d()->rangeErrorConstructor);
putDirect("ReferenceError", d()->referenceErrorConstructor);
putDirect("SyntaxError", d()->syntaxErrorConstructor);
putDirect("TypeError", d()->typeErrorConstructor);
putDirect("URIError", d()->URIErrorConstructor);
// Set global values.
......
......@@ -149,7 +149,8 @@ namespace KJS {
virtual ~JSGlobalObject();
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None);
virtual void put(ExecState*, const Identifier&, JSValue*);
virtual void initializeVariable(ExecState*, const Identifier&, JSValue*, unsigned attributes);
// Linked list of all global objects.
static JSGlobalObject* head() { return s_head; }
......
......@@ -42,6 +42,8 @@ namespace KJS {
void saveLocalStorage(SavedProperties&) const;
void restoreLocalStorage(const SavedProperties&);
virtual void initializeVariable(ExecState*, const Identifier&, JSValue*, unsigned attributes) = 0;
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
......@@ -77,7 +79,8 @@ namespace KJS {
}
bool symbolTableGet(const Identifier&, PropertySlot&);
bool symbolTablePut(const Identifier&, JSValue*, bool checkReadOnly);
bool symbolTablePut(const Identifier&, JSValue*);
bool symbolTableInitializeVariable(const Identifier&, JSValue*, unsigned attributes);
JSVariableObjectData* d;
};
......@@ -104,18 +107,29 @@ namespace KJS {
return false;
}
inline bool JSVariableObject::symbolTablePut(const Identifier& propertyName, JSValue* value, bool checkReadOnly)
inline bool JSVariableObject::symbolTablePut(const Identifier& propertyName, JSValue* value)
{
size_t index = symbolTable().get(propertyName.ustring().rep());
if (index == missingSymbolMarker())
return false;
LocalStorageEntry& entry = d->localStorage[index];
if (checkReadOnly && (entry.attributes & ReadOnly))
if (entry.attributes & ReadOnly)
return true;
entry.value = value;
return true;
}
inline bool JSVariableObject::symbolTableInitializeVariable(const Identifier& propertyName, JSValue* value, unsigned attributes)
{
size_t index = symbolTable().get(propertyName.ustring().rep());
if (index == missingSymbolMarker())
return false;
LocalStorageEntry& entry = d->localStorage[index];
entry.value = value;
entry.attributes = attributes;
return true;
}
} // namespace KJS
#endif // JSVariableObject_h
......@@ -184,12 +184,12 @@ bool ArrayInstance::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot
}
// ECMA 15.4.5.1
void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attributes)
void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
bool isArrayIndex;
unsigned i = propertyName.toArrayIndex(&isArrayIndex);
if (isArrayIndex) {
put(exec, i, value, attributes);
put(exec, i, value);
return;
}
......@@ -203,13 +203,13 @@ void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue
return;
}
JSObject::put(exec, propertyName, value, attributes);
JSObject::put(exec, propertyName, value);
}
void ArrayInstance::put(ExecState* exec, unsigned i, JSValue* value, int attributes)
void ArrayInstance::put(ExecState* exec, unsigned i, JSValue* value)
{
if (i > maxArrayIndex) {
put(exec, Identifier::from(i), value, attributes);
put(exec, Identifier::from(i), value);
return;
}
......
......@@ -36,8 +36,8 @@ namespace KJS {
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attributes = None);
virtual void put(ExecState*, unsigned propertyName, JSValue*, int attributes = None);
virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
virtual void put(ExecState*, unsigned propertyName, JSValue*);
virtual bool deleteProperty(ExecState *, const Identifier& propertyName);
virtual bool deleteProperty(ExecState *, unsigned propertyName);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
......
......@@ -148,11 +148,11 @@ bool FunctionImp::getOwnPropertySlot(ExecState* exec, const Identifier& property
return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot);
}
void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return;
InternalFunctionImp::put(exec, propertyName, value, attr);
InternalFunctionImp::put(exec, propertyName, value);
}
bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
......@@ -320,13 +320,12 @@ bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyNa
return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
if (indexToNameMap.isMapped(propertyName)) {
_activationObject->put(exec, indexToNameMap[propertyName], value, attr);
} else {
JSObject::put(exec, propertyName, value, attr);
}
if (indexToNameMap.isMapped(propertyName))
_activationObject->put(exec, indexToNameMap[propertyName], value);
else
JSObject::put(exec, propertyName, value);
}
bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
......@@ -417,18 +416,28 @@ bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyNa
return JSVariableObject::deleteProperty(exec, propertyName);
}
void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr)
void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value)
{
if (symbolTablePut(propertyName, value))
return;
// We don't call through to JSObject because __proto__ and getter/setter
// properties are non-standard extensions that other implementations do not
// expose in the activation object.
ASSERT(!_prop.hasGetterSetterProperties());
_prop.put(propertyName, value, 0, true);
}
void ActivationImp::initializeVariable(ExecState*, const Identifier& propertyName, JSValue* value, unsigned attributes)
{
// If any bits other than DontDelete are set, then we bypass the read-only check.
bool checkReadOnly = !(attr & ~DontDelete);
if (symbolTablePut(propertyName, value, checkReadOnly))
if (symbolTableInitializeVariable(propertyName, value, attributes))
return;
// We don't call through to JSObject because __proto__ and getter/setter
// properties are non-standard extensions that other implementations do not
// expose in the activation object.
ASSERT(!_prop.hasGetterSetterProperties());
_prop.put(propertyName, value, attr, checkReadOnly);
_prop.put(propertyName, value, attributes, true);
}
void ActivationImp::markChildren()
......
......@@ -61,7 +61,7 @@ namespace KJS {
FunctionImp(ExecState*, const Identifier& name, FunctionBodyNode*, const ScopeChain&);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual void put(ExecState*, <