JavaScriptCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2007 05:43:47 +0000 (05:43 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2007 05:43:47 +0000 (05:43 +0000)
        Reviewed by Mark.

        - avoid static construction (and global variable access) in a smarter, more portable way,
        to later enable MUTLI_THREAD mode to work on other platforms and compilers.

        * kjs/CommonIdentifiers.cpp: Added. New class to hold all the shared identifiers.
        (KJS::CommonIdentifiers::CommonIdentifiers):
        (KJS::CommonIdentifiers::shared):
        * kjs/CommonIdentifiers.h: Added.

        * kjs/ExecState.h:
        (KJS::ExecState::propertyNames): Hand the CommonIdentifiers instance here for easy access.
        (KJS::ExecState::ExecState):

        * API/JSObjectRef.cpp:
        (JSObjectMakeConstructor):
        * CMakeLists.txt:
        * JavaScriptCore.exp:
        * JavaScriptCore.pri:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * JavaScriptCoreSources.bkl:
        * bindings/runtime_array.cpp:
        (RuntimeArray::getOwnPropertySlot):
        (RuntimeArray::put):
        * bindings/runtime_method.cpp:
        (RuntimeMethod::getOwnPropertySlot):
        * kjs/array_object.cpp:
        (ArrayInstance::getOwnPropertySlot):
        (ArrayInstance::put):
        (ArrayInstance::deleteProperty):
        (ArrayProtoFunc::ArrayProtoFunc):
        (ArrayProtoFunc::callAsFunction):
        (ArrayObjectImp::ArrayObjectImp):
        * kjs/bool_object.cpp:
        (BooleanPrototype::BooleanPrototype):
        (BooleanProtoFunc::BooleanProtoFunc):
        (BooleanProtoFunc::callAsFunction):
        (BooleanObjectImp::BooleanObjectImp):
        * kjs/completion.h:
        (KJS::Completion::Completion):
        * kjs/date_object.cpp:
        (KJS::DateProtoFunc::DateProtoFunc):
        (KJS::DateObjectImp::DateObjectImp):
        (KJS::DateObjectFuncImp::DateObjectFuncImp):
        * kjs/error_object.cpp:
        (ErrorPrototype::ErrorPrototype):
        (ErrorProtoFunc::ErrorProtoFunc):
        (ErrorProtoFunc::callAsFunction):
        (ErrorObjectImp::ErrorObjectImp):
        (ErrorObjectImp::construct):
        (NativeErrorPrototype::NativeErrorPrototype):
        (NativeErrorImp::NativeErrorImp):
        (NativeErrorImp::construct):
        (NativeErrorImp::callAsFunction):
        * kjs/function.cpp:
        (KJS::FunctionImp::getOwnPropertySlot):
        (KJS::FunctionImp::put):
        (KJS::FunctionImp::deleteProperty):
        (KJS::FunctionImp::getParameterName):
        (KJS::DeclaredFunctionImp::construct):
        (KJS::IndexToNameMap::unMap):
        (KJS::Arguments::Arguments):
        (KJS::ActivationImp::getOwnPropertySlot):
        (KJS::ActivationImp::deleteProperty):
        (KJS::GlobalFuncImp::GlobalFuncImp):
        * kjs/function_object.cpp:
        (FunctionPrototype::FunctionPrototype):
        (FunctionProtoFunc::FunctionProtoFunc):
        (FunctionProtoFunc::callAsFunction):
        (FunctionObjectImp::FunctionObjectImp):
        (FunctionObjectImp::construct):
        * kjs/grammar.y:
        * kjs/identifier.cpp:
        * kjs/identifier.h:
        * kjs/interpreter.cpp:
        (KJS::Interpreter::init):
        (KJS::Interpreter::initGlobalObject):
        * kjs/interpreter.h:
        * kjs/lookup.h:
        * kjs/math_object.cpp:
        (MathFuncImp::MathFuncImp):
        * kjs/nodes.cpp:
        (ArrayNode::evaluate):
        (FuncDeclNode::processFuncDecl):
        (FuncExprNode::evaluate):
        * kjs/number_object.cpp:
        (NumberPrototype::NumberPrototype):
        (NumberProtoFunc::NumberProtoFunc):
        (NumberObjectImp::NumberObjectImp):
        * kjs/object.cpp:
        (KJS::JSObject::put):
        (KJS::JSObject::defaultValue):
        (KJS::JSObject::hasInstance):
        * kjs/object.h:
        (KJS::JSObject::getOwnPropertySlot):
        * kjs/object_object.cpp:
        (ObjectPrototype::ObjectPrototype):
        (ObjectProtoFunc::ObjectProtoFunc):
        (ObjectObjectImp::ObjectObjectImp):
        * kjs/regexp_object.cpp:
        (RegExpPrototype::RegExpPrototype):
        (RegExpProtoFunc::RegExpProtoFunc):
        (RegExpObjectImp::RegExpObjectImp):
        * kjs/string_object.cpp:
        (KJS::StringInstance::getOwnPropertySlot):
        (KJS::StringInstance::put):
        (KJS::StringInstance::deleteProperty):
        (KJS::StringPrototype::StringPrototype):
        (KJS::StringProtoFunc::StringProtoFunc):
        (KJS::StringProtoFunc::callAsFunction):
        (KJS::StringObjectImp::StringObjectImp):
        (KJS::StringObjectFuncImp::StringObjectFuncImp):
        * kjs/testkjs.cpp:
        (TestFunctionImp::TestFunctionImp):

WebCore:

        Reviewed by Mark.

        - avoid static construction (and global variable access) in a smarter, more portable way,
        to later enable MUTLI_THREAD mode to work on other platforms and compilers.

        * bindings/js/JSCustomXPathNSResolver.cpp:
        (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
        * bindings/js/JSHTMLInputElementBase.cpp:
        (WebCore::JSHTMLInputElementBaseFunction::JSHTMLInputElementBaseFunction):
        * bindings/js/JSHTMLOptionElementConstructor.cpp:
        (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
        * bindings/js/JSXMLHttpRequest.cpp:
        (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp):
        * bindings/js/JSXSLTProcessor.cpp:
        (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
        * bindings/js/kjs_dom.cpp:
        (KJS::DOMNamedNodeMap::getOwnPropertySlot):
        (KJS::DOMNamedNodesCollection::getOwnPropertySlot):
        * bindings/js/kjs_events.cpp:
        (KJS::JSAbstractEventListener::handleEvent):
        * bindings/js/kjs_html.cpp:
        (KJS::HTMLElementFunction::HTMLElementFunction):
        (KJS::JSHTMLCollection::getOwnPropertySlot):
        * bindings/js/kjs_window.cpp:
        (KJS::ScheduledAction::execute):
        * bindings/objc/WebScriptObject.mm:
        * bindings/scripts/CodeGeneratorJS.pm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20310 268f45cc-cd09-0410-ab3c-d52691b4dbfc

47 files changed:
JavaScriptCore/API/JSObjectRef.cpp
JavaScriptCore/CMakeLists.txt
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/JavaScriptCore.pri
JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/JavaScriptCoreSources.bkl
JavaScriptCore/bindings/runtime_array.cpp
JavaScriptCore/bindings/runtime_method.cpp
JavaScriptCore/kjs/CommonIdentifiers.cpp [new file with mode: 0644]
JavaScriptCore/kjs/CommonIdentifiers.h [new file with mode: 0644]
JavaScriptCore/kjs/ExecState.h
JavaScriptCore/kjs/array_object.cpp
JavaScriptCore/kjs/bool_object.cpp
JavaScriptCore/kjs/completion.h
JavaScriptCore/kjs/date_object.cpp
JavaScriptCore/kjs/error_object.cpp
JavaScriptCore/kjs/function.cpp
JavaScriptCore/kjs/function_object.cpp
JavaScriptCore/kjs/grammar.y
JavaScriptCore/kjs/identifier.cpp
JavaScriptCore/kjs/identifier.h
JavaScriptCore/kjs/interpreter.cpp
JavaScriptCore/kjs/interpreter.h
JavaScriptCore/kjs/lookup.h
JavaScriptCore/kjs/math_object.cpp
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/number_object.cpp
JavaScriptCore/kjs/object.cpp
JavaScriptCore/kjs/object.h
JavaScriptCore/kjs/object_object.cpp
JavaScriptCore/kjs/regexp_object.cpp
JavaScriptCore/kjs/string_object.cpp
JavaScriptCore/kjs/testkjs.cpp
WebCore/ChangeLog
WebCore/bindings/js/JSCustomXPathNSResolver.cpp
WebCore/bindings/js/JSHTMLInputElementBase.cpp
WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
WebCore/bindings/js/JSXMLHttpRequest.cpp
WebCore/bindings/js/JSXSLTProcessor.cpp
WebCore/bindings/js/kjs_dom.cpp
WebCore/bindings/js/kjs_events.cpp
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_window.cpp
WebCore/bindings/objc/WebScriptObject.mm
WebCore/bindings/scripts/CodeGeneratorJS.pm

index 228b2ad..3b082d6 100644 (file)
@@ -100,7 +100,7 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
         : exec->dynamicInterpreter()->builtinObjectPrototype();
     
     JSObject* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
-    constructor->put(exec, prototypePropertyName, jsPrototype, DontEnum|DontDelete|ReadOnly);
+    constructor->put(exec, exec->propertyNames().prototype, jsPrototype, DontEnum|DontDelete|ReadOnly);
     return toRef(constructor);
 }
 
index b55dcba..cf1c582 100644 (file)
@@ -92,6 +92,7 @@ set(kjs-unity_LIB_SRCS
     kjs/array_object.cpp
     kjs/bool_object.cpp
     kjs/collector.cpp
+    kjs/CommonIdentifiers.cpp
     kjs/Context.cpp
     kjs/date_object.cpp
     kjs/debugger.cpp
index 786c37e..d46dfac 100644 (file)
@@ -1,3 +1,121 @@
+2007-03-18  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Mark.
+        
+        - avoid static construction (and global variable access) in a smarter, more portable way,
+        to later enable MUTLI_THREAD mode to work on other platforms and compilers.
+        
+        * kjs/CommonIdentifiers.cpp: Added. New class to hold all the shared identifiers.
+        (KJS::CommonIdentifiers::CommonIdentifiers):
+        (KJS::CommonIdentifiers::shared):
+        * kjs/CommonIdentifiers.h: Added.
+
+        * kjs/ExecState.h:
+        (KJS::ExecState::propertyNames): Hand the CommonIdentifiers instance here for easy access.
+        (KJS::ExecState::ExecState):
+
+        * API/JSObjectRef.cpp:
+        (JSObjectMakeConstructor):
+        * CMakeLists.txt:
+        * JavaScriptCore.exp:
+        * JavaScriptCore.pri:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * JavaScriptCoreSources.bkl:
+        * bindings/runtime_array.cpp:
+        (RuntimeArray::getOwnPropertySlot):
+        (RuntimeArray::put):
+        * bindings/runtime_method.cpp:
+        (RuntimeMethod::getOwnPropertySlot):
+        * kjs/array_object.cpp:
+        (ArrayInstance::getOwnPropertySlot):
+        (ArrayInstance::put):
+        (ArrayInstance::deleteProperty):
+        (ArrayProtoFunc::ArrayProtoFunc):
+        (ArrayProtoFunc::callAsFunction):
+        (ArrayObjectImp::ArrayObjectImp):
+        * kjs/bool_object.cpp:
+        (BooleanPrototype::BooleanPrototype):
+        (BooleanProtoFunc::BooleanProtoFunc):
+        (BooleanProtoFunc::callAsFunction):
+        (BooleanObjectImp::BooleanObjectImp):
+        * kjs/completion.h:
+        (KJS::Completion::Completion):
+        * kjs/date_object.cpp:
+        (KJS::DateProtoFunc::DateProtoFunc):
+        (KJS::DateObjectImp::DateObjectImp):
+        (KJS::DateObjectFuncImp::DateObjectFuncImp):
+        * kjs/error_object.cpp:
+        (ErrorPrototype::ErrorPrototype):
+        (ErrorProtoFunc::ErrorProtoFunc):
+        (ErrorProtoFunc::callAsFunction):
+        (ErrorObjectImp::ErrorObjectImp):
+        (ErrorObjectImp::construct):
+        (NativeErrorPrototype::NativeErrorPrototype):
+        (NativeErrorImp::NativeErrorImp):
+        (NativeErrorImp::construct):
+        (NativeErrorImp::callAsFunction):
+        * kjs/function.cpp:
+        (KJS::FunctionImp::getOwnPropertySlot):
+        (KJS::FunctionImp::put):
+        (KJS::FunctionImp::deleteProperty):
+        (KJS::FunctionImp::getParameterName):
+        (KJS::DeclaredFunctionImp::construct):
+        (KJS::IndexToNameMap::unMap):
+        (KJS::Arguments::Arguments):
+        (KJS::ActivationImp::getOwnPropertySlot):
+        (KJS::ActivationImp::deleteProperty):
+        (KJS::GlobalFuncImp::GlobalFuncImp):
+        * kjs/function_object.cpp:
+        (FunctionPrototype::FunctionPrototype):
+        (FunctionProtoFunc::FunctionProtoFunc):
+        (FunctionProtoFunc::callAsFunction):
+        (FunctionObjectImp::FunctionObjectImp):
+        (FunctionObjectImp::construct):
+        * kjs/grammar.y:
+        * kjs/identifier.cpp:
+        * kjs/identifier.h:
+        * kjs/interpreter.cpp:
+        (KJS::Interpreter::init):
+        (KJS::Interpreter::initGlobalObject):
+        * kjs/interpreter.h:
+        * kjs/lookup.h:
+        * kjs/math_object.cpp:
+        (MathFuncImp::MathFuncImp):
+        * kjs/nodes.cpp:
+        (ArrayNode::evaluate):
+        (FuncDeclNode::processFuncDecl):
+        (FuncExprNode::evaluate):
+        * kjs/number_object.cpp:
+        (NumberPrototype::NumberPrototype):
+        (NumberProtoFunc::NumberProtoFunc):
+        (NumberObjectImp::NumberObjectImp):
+        * kjs/object.cpp:
+        (KJS::JSObject::put):
+        (KJS::JSObject::defaultValue):
+        (KJS::JSObject::hasInstance):
+        * kjs/object.h:
+        (KJS::JSObject::getOwnPropertySlot):
+        * kjs/object_object.cpp:
+        (ObjectPrototype::ObjectPrototype):
+        (ObjectProtoFunc::ObjectProtoFunc):
+        (ObjectObjectImp::ObjectObjectImp):
+        * kjs/regexp_object.cpp:
+        (RegExpPrototype::RegExpPrototype):
+        (RegExpProtoFunc::RegExpProtoFunc):
+        (RegExpObjectImp::RegExpObjectImp):
+        * kjs/string_object.cpp:
+        (KJS::StringInstance::getOwnPropertySlot):
+        (KJS::StringInstance::put):
+        (KJS::StringInstance::deleteProperty):
+        (KJS::StringPrototype::StringPrototype):
+        (KJS::StringProtoFunc::StringProtoFunc):
+        (KJS::StringProtoFunc::callAsFunction):
+        (KJS::StringObjectImp::StringObjectImp):
+        (KJS::StringObjectFuncImp::StringObjectFuncImp):
+        * kjs/testkjs.cpp:
+        (TestFunctionImp::TestFunctionImp):
+
 2007-03-18  Andrew Wellington  <proton@wiretapped.net>
 
         Reviewed by Mark Rowe
index 2801627..d736e5e 100644 (file)
@@ -151,11 +151,8 @@ __ZN3KJS15SavedPropertiesD1Ev
 __ZN3KJS16RuntimeObjectImp4infoE
 __ZN3KJS16RuntimeObjectImpC1EPNS_8Bindings8InstanceE
 __ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
-__ZN3KJS18lengthPropertyNameE
 __ZN3KJS19InternalFunctionImp4infoE
 __ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
-__ZN3KJS19messagePropertyNameE
-__ZN3KJS21prototypePropertyNameE
 __ZN3KJS4List6appendEPNS_7JSValueE
 __ZN3KJS4List7releaseEv
 __ZN3KJS4ListC1Ev
index 2a7d6fa..670f9d1 100644 (file)
@@ -47,6 +47,7 @@ SOURCES += \
     kjs/array_object.cpp \
     kjs/bool_object.cpp \
     kjs/collector.cpp \
+    kjs/CommonIdentifiers.cpp \
     kjs/Context.cpp \
     kjs/date_object.cpp \
     kjs/debugger.cpp \
index 62db485..c039c85 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\..\kjs\CommonIdentifiers.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\kjs\CommonIdentifiers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\kjs\config.h"
                                >
                        </File>
index 3f3c085..7b2fa22 100644 (file)
                65E217C008E7EECC0023E5F6 /* FastMalloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E217BA08E7EECC0023E5F6 /* FastMalloc.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65EA4C9B092AF9E20093D800 /* JSLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65EA4C99092AF9E20093D800 /* JSLock.cpp */; };
                65EA4C9C092AF9E20093D800 /* JSLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EA4C9A092AF9E20093D800 /* JSLock.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               65EA73640BAE35D1001BB560 /* CommonIdentifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */; };
+               65EA73650BAE35D1001BB560 /* CommonIdentifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65FB3EB309D109F000F49DEB /* lexer.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FB3EB209D109F000F49DEB /* lexer.lut.h */; };
                65FB3F4F09D11B2400F49DEB /* date_object.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FB3F4709D11B2400F49DEB /* date_object.lut.h */; };
                65FB3F5009D11B2400F49DEB /* grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FB3F4809D11B2400F49DEB /* grammar.cpp */; };
                65E217BA08E7EECC0023E5F6 /* FastMalloc.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = FastMalloc.h; sourceTree = "<group>"; tabWidth = 8; };
                65EA4C99092AF9E20093D800 /* JSLock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLock.cpp; sourceTree = "<group>"; tabWidth = 8; };
                65EA4C9A092AF9E20093D800 /* JSLock.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JSLock.h; sourceTree = "<group>"; tabWidth = 8; };
+               65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CommonIdentifiers.cpp; sourceTree = "<group>"; };
+               65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CommonIdentifiers.h; sourceTree = "<group>"; };
                65FB3EB209D109F000F49DEB /* lexer.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lexer.lut.h; sourceTree = "<group>"; };
                65FB3F4709D11B2400F49DEB /* date_object.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = date_object.lut.h; sourceTree = "<group>"; };
                65FB3F4809D11B2400F49DEB /* grammar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = grammar.cpp; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
+                               65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */,
+                               65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */,
                                65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
                                65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */,
                                65400C100A69BAF200509887 /* PropertyNameArray.h */,
                                E11D51760B2E798D0056C188 /* StringExtras.h in Headers */,
                                146AAB2B0B66A84900E55F16 /* JSStringRefCF.h in Headers */,
                                657EB7460B708F540063461B /* ListHashSet.h in Headers */,
+                               65EA73650BAE35D1001BB560 /* CommonIdentifiers.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                D212022A0AD4310D00ED79B6 /* DateMath.cpp in Sources */,
                                146AAB380B66A94400E55F16 /* JSStringRefCF.cpp in Sources */,
                                9302043B0B790750000C6115 /* FastMallocPCRE.cpp in Sources */,
+                               65EA73640BAE35D1001BB560 /* CommonIdentifiers.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 340e5cb..971da16 100644 (file)
@@ -2,6 +2,7 @@
 <makefile>
     <set append="1" var="JSCORE_SOURCES_KJS">
         DerivedSources/JavaScriptCore/grammar.cpp
+        kjs/CommonIdentifiers.cpp
         kjs/Context.cpp
         kjs/DateMath.cpp
         kjs/ExecState.cpp
index 627da93..2efae5f 100644 (file)
@@ -54,9 +54,9 @@ JSValue *RuntimeArray::indexGetter(ExecState* exec, JSObject*, const Identifier&
     return thisObj->getConcreteArray()->valueAt(exec, slot.index());
 }
 
-bool RuntimeArray::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool RuntimeArray::getOwnPropertySlot(ExecStateexec, const Identifier& propertyName, PropertySlot& slot)
 {
-    if (propertyName == lengthPropertyName) {
+    if (propertyName == exec->propertyNames().length) {
         slot.setCustom(this, lengthGetter);
         return true;
     }
@@ -83,9 +83,9 @@ bool RuntimeArray::getOwnPropertySlot(ExecState *exec, unsigned index, PropertyS
     return ArrayInstance::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, int attr)
 {
-    if (propertyName == lengthPropertyName) {
+    if (propertyName == exec->propertyNames().length) {
         throwError(exec, RangeError);
         return;
     }
index 3baf87a..f46485e 100644 (file)
@@ -56,9 +56,9 @@ JSValue *RuntimeMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, c
     return jsNumber(thisObj->_methodList.methodAt(0)->numParameters());
 }
 
-bool RuntimeMethod::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
+bool RuntimeMethod::getOwnPropertySlot(ExecStateexec, const Identifier& propertyName, PropertySlot &slot)
 {
-    if (propertyName == lengthPropertyName) {
+    if (propertyName == exec->propertyNames().length) {
         slot.setCustom(this, lengthGetter);
         return true;
     }
diff --git a/JavaScriptCore/kjs/CommonIdentifiers.cpp b/JavaScriptCore/kjs/CommonIdentifiers.cpp
new file mode 100644 (file)
index 0000000..30996c9
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  Copyright (C) 2003, 2007 Apple Computer, Inc
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "CommonIdentifiers.h"
+
+namespace KJS {
+
+const char* const nullCString = 0;
+
+#define INITIALIZE_PROPERTY_NAME(name) , name ( #name )
+
+CommonIdentifiers::CommonIdentifiers()
+    : nullIdentifier(nullCString)
+    , underscoreProto("__proto__")
+    KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME)
+{
+}
+
+CommonIdentifiers* CommonIdentifiers::shared()
+{
+    static CommonIdentifiers* sharedInstance;
+    if (!sharedInstance) {
+        JSLock lock;
+        sharedInstance = new CommonIdentifiers;
+    }
+    return sharedInstance;
+}
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/CommonIdentifiers.h b/JavaScriptCore/kjs/CommonIdentifiers.h
new file mode 100644 (file)
index 0000000..e63faeb
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  Copyright (C) 2003,2007 Apple Computer, Inc
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_COMMON_IDENTIFIERS_H
+#define KJS_COMMON_IDENTIFIERS_H
+
+#include "identifier.h"
+#include <wtf/Noncopyable.h>
+
+// List of property names, passed to a macro so we can do set them up various
+// ways without repeating the list.
+#define KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
+    macro(arguments) \
+    macro(callee) \
+    macro(caller) \
+    macro(constructor) \
+    macro(fromCharCode) \
+    macro(length) \
+    macro(message) \
+    macro(name) \
+    macro(prototype) \
+    macro(toLocaleString) \
+    macro(toString) \
+    macro(toFixed) \
+    macro(toExponential) \
+    macro(toPrecision) \
+    macro(valueOf)
+
+namespace KJS {
+
+    class CommonIdentifiers : Noncopyable {
+
+    private:
+        CommonIdentifiers();
+
+    public:
+        static CommonIdentifiers* shared();
+
+        const Identifier nullIdentifier;
+        const Identifier underscoreProto;
+
+#define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name;
+        KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
+#undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
+    };
+} // namespace KJS
+
+#endif // KJS_COMMON_IDENTIFIERS_H
+
index c16b50d..6a3796e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "value.h"
 #include "types.h"
+#include "CommonIdentifiers.h"
 
 namespace KJS {
     class Context;
@@ -75,16 +76,22 @@ namespace KJS {
     JSValue** exceptionSlot() { return &m_exception; }
     bool hadException() const { return !!m_exception; }
 
+    // This is a workaround to avoid accessing the global variables for these identifiers in
+    // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
+    const CommonIdentifiers& propertyNames() const { return *m_propertyNames; }
+
   private:
     ExecState(Interpreter* interp, Context* con)
         : m_interpreter(interp)
         , m_context(con)
         , m_exception(0)
+        , m_propertyNames(CommonIdentifiers::shared())
     { 
     }
     Interpreter* m_interpreter;
     Context* m_context;
     JSValue* m_exception;
+    CommonIdentifiers* m_propertyNames;
   };
 
 } // namespace KJS
index 9892a76..69db2bd 100644 (file)
@@ -89,7 +89,7 @@ JSValue *ArrayInstance::lengthGetter(ExecState*, JSObject*, const Identifier&, c
 
 bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
-  if (propertyName == lengthPropertyName) {
+  if (propertyName == exec->propertyNames().length) {
     slot.setCustom(this, lengthGetter);
     return true;
   }
@@ -130,9 +130,9 @@ bool ArrayInstance::getOwnPropertySlot(ExecState *exec, unsigned index, Property
 }
 
 // Special implementation of [[Put]] - see ECMA 15.4.5.1
-void ArrayInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
 {
-  if (propertyName == lengthPropertyName) {
+  if (propertyName == exec->propertyNames().length) {
     unsigned int newLen = value->toUInt32(exec);
     if (value->toNumber(exec) != double(newLen)) {
       throwError(exec, RangeError, "Invalid array length.");
@@ -178,9 +178,9 @@ void ArrayInstance::put(ExecState *exec, unsigned index, JSValue *value, int att
   JSObject::put(exec, Identifier::from(index), value, attr);
 }
 
-bool ArrayInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
+bool ArrayInstance::deleteProperty(ExecStateexec, const Identifier &propertyName)
 {
-  if (propertyName == lengthPropertyName)
+  if (propertyName == exec->propertyNames().length)
     return false;
   
   bool ok;
@@ -435,12 +435,12 @@ bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& prope
 
 // ------------------------------ ArrayProtoFunc ----------------------------
 
-ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
+ArrayProtoFunc::ArrayProtoFunc(ExecStateexec, int i, int len, const Identifier& name)
   : InternalFunctionImp(static_cast<FunctionPrototype*>
                         (exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
   , id(i)
 {
-  put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
+  put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
 }
 
 static JSValue *getProperty(ExecState *exec, JSObject *obj, unsigned index)
@@ -452,9 +452,9 @@ static JSValue *getProperty(ExecState *exec, JSObject *obj, unsigned index)
 }
 
 // ECMA 15.4.4
-JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
 {
-  unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec);
+  unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
 
   JSValue *result = 0; // work around gcc 4.0 bug in uninitialized variable warning
   
@@ -487,7 +487,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
         bool fallback = false;
         if (id == ToLocaleString) {
             JSObject* o = element->toObject(exec);
-            JSValue* conversionFunction = o->get(exec, toLocaleStringPropertyName);
+            JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString);
             if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall())
                 str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec);
             else
@@ -517,7 +517,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
         unsigned int k = 0;
         // Older versions tried to optimize out getting the length of thisObj
         // by checking for n != 0, but that doesn't work if thisObj is an empty array.
-        length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
+        length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
         while (k < length) {
           if (JSValue *v = getProperty(exec, curObj, k))
             arr->put(exec, n, v);
@@ -533,18 +533,18 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
       curArg = *it;
       curObj = static_cast<JSObject *>(it++); // may be 0
     }
-    arr->put(exec,lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
+    arr->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete);
 
     result = arr;
     break;
   }
   case Pop:{
     if (length == 0) {
-      thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
+      thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
       result = jsUndefined();
     } else {
       result = thisObj->get(exec, length - 1);
-      thisObj->put(exec, lengthPropertyName, jsNumber(length - 1), DontEnum | DontDelete);
+      thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1), DontEnum | DontDelete);
     }
     break;
   }
@@ -552,7 +552,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
     for (int n = 0; n < args.size(); n++)
       thisObj->put(exec, length + n, args[n]);
     length += args.size();
-    thisObj->put(exec,lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
+    thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
     result = jsNumber(length);
     break;
   }
@@ -580,7 +580,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
   }
   case Shift: {
     if (length == 0) {
-      thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
+      thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
       result = jsUndefined();
     } else {
       result = thisObj->get(exec, 0);
@@ -591,7 +591,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
           thisObj->deleteProperty(exec, k-1);
       }
       thisObj->deleteProperty(exec, length - 1);
-      thisObj->put(exec, lengthPropertyName, jsNumber(length - 1), DontEnum | DontDelete);
+      thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1), DontEnum | DontDelete);
     }
     break;
   }
@@ -634,7 +634,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
       if (JSValue *v = getProperty(exec, thisObj, k))
         resObj->put(exec, n, v);
     }
-    resObj->put(exec, lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
+    resObj->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete);
     break;
   }
   case Sort:{
@@ -661,7 +661,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
     }
 
     if (length == 0) {
-      thisObj->put(exec, lengthPropertyName, jsNumber(0), DontEnum | DontDelete);
+      thisObj->put(exec, exec->propertyNames().length, jsNumber(0), DontEnum | DontDelete);
       result = thisObj;
       break;
     }
@@ -727,7 +727,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
       if (JSValue *v = getProperty(exec, thisObj, k+begin))
         resObj->put(exec, k, v);
     }
-    resObj->put(exec, lengthPropertyName, jsNumber(deleteCount), DontEnum | DontDelete);
+    resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount), DontEnum | DontDelete);
 
     unsigned int additionalArgs = maxInt( args.size() - 2, 0 );
     if ( additionalArgs != deleteCount )
@@ -759,7 +759,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
     {
       thisObj->put(exec, k+begin, args[k+2]);
     }
-    thisObj->put(exec, lengthPropertyName, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
+    thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
     break;
   }
   case UnShift: { // 15.4.4.13
@@ -774,7 +774,7 @@ JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
     for ( unsigned int k = 0; k < nrArgs; ++k )
       thisObj->put(exec, k, args[k]);
     result = jsNumber(length + nrArgs);
-    thisObj->put(exec, lengthPropertyName, result, DontEnum | DontDelete);
+    thisObj->put(exec, exec->propertyNames().length, result, DontEnum | DontDelete);
     break;
   }
   case Filter:
@@ -934,10 +934,10 @@ ArrayObjectImp::ArrayObjectImp(ExecState *exec,
   : InternalFunctionImp(funcProto)
 {
   // ECMA 15.4.3.1 Array.prototype
-  put(exec, prototypePropertyName, arrayProto, DontEnum|DontDelete|ReadOnly);
+  put(exec, exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
 
   // no. of arguments for constructor
-  put(exec, lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+  put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 bool ArrayObjectImp::implementsConstruct() const
index 8c12d68..fc035e7 100644 (file)
@@ -46,24 +46,24 @@ BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectProto
 {
   // The constructor will be added later by Interpreter::Interpreter()
 
-  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
-  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, valueOfPropertyName),  DontEnum);
+  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
+  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, exec->propertyNames().valueOf),  DontEnum);
   setInternalValue(jsBoolean(false));
 }
 
 
 // ------------------------------ BooleanProtoFunc --------------------------
 
-BooleanProtoFunc::BooleanProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+BooleanProtoFunc::BooleanProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
   : InternalFunctionImp(funcProto, name)
   , id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
 }
 
 
 // ECMA 15.6.4.2 + 15.6.4.3
-JSValue *BooleanProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
+JSValue *BooleanProtoFunc::callAsFunction(ExecStateexec, JSObject *thisObj, const List &/*args*/)
 {
   // no generic function. "this" has to be a Boolean object
   if (!thisObj->inherits(&BooleanInstance::info))
@@ -82,13 +82,13 @@ JSValue *BooleanProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, co
 // ------------------------------ BooleanObjectImp -----------------------------
 
 
-BooleanObjectImp::BooleanObjectImp(ExecState*, FunctionPrototype* funcProto, BooleanPrototype* booleanProto)
+BooleanObjectImp::BooleanObjectImp(ExecState* exec, FunctionPrototype* funcProto, BooleanPrototype* booleanProto)
   : InternalFunctionImp(funcProto)
 {
-  putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, booleanProto, DontEnum|DontDelete|ReadOnly);
 
   // no. of arguments for constructor
-  putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 
index a06e60e..ceb2b44 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef _KJS_COMPLETION_H_
 #define _KJS_COMPLETION_H_
 
-#include "identifier.h"
+#include "CommonIdentifiers.h"
 #include "value.h"
 
 namespace KJS {
@@ -47,7 +47,7 @@ namespace KJS {
    */
   class Completion {
   public:
-    Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = Identifier::null())
+    Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = CommonIdentifiers::shared()->nullIdentifier)
         : comp(c), val(v), tar(t) { }
 
     ComplType complType() const { return comp; }
index 7c0fb78..a05c4ed 100644 (file)
@@ -433,13 +433,13 @@ bool DatePrototype::getOwnPropertySlot(ExecState *exec, const Identifier& proper
 
 // ------------------------------ DateProtoFunc -----------------------------
 
-DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
+DateProtoFunc::DateProtoFunc(ExecStateexec, int i, int len, const Identifier& name)
   : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
   , id(abs(i))
   , utc(i < 0)
   // We use a negative ID to denote the "UTC" variant.
 {
-    putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+    putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
 }
 
 JSValue *DateProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
@@ -599,10 +599,10 @@ DateObjectImp::DateObjectImp(ExecState *exec,
   static const Identifier* parsePropertyName = new Identifier("parse");
   static const Identifier* UTCPropertyName = new Identifier("UTC");
 
-  putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
   putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum);
   putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum);
-  putDirect(lengthPropertyName, 7, ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
 }
 
 bool DateObjectImp::implementsConstruct() const
@@ -668,10 +668,10 @@ JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisOb
 
 // ------------------------------ DateObjectFuncImp ----------------------------
 
-DateObjectFuncImp::DateObjectFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     : InternalFunctionImp(funcProto, name), id(i)
 {
-    putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+    putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
 }
 
 // ECMA 15.9.4.2 - 3
index 1c323db..8cbdd0f 100644 (file)
@@ -43,37 +43,35 @@ ErrorInstance::ErrorInstance(JSObject *proto)
 // ------------------------------ ErrorPrototype ----------------------------
 
 // ECMA 15.9.4
-ErrorPrototype::ErrorPrototype(ExecState *exec,
-                                     ObjectPrototype *objectProto,
-                                     FunctionPrototype *funcProto)
+ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectProto, FunctionPrototype* funcProto)
   : JSObject(objectProto)
 {
   // The constructor will be added later in ErrorObjectImp's constructor
 
-  put(exec, namePropertyName,     jsString("Error"), DontEnum);
-  put(exec, messagePropertyName,  jsString("Unknown error"), DontEnum);
-  putDirectFunction(new ErrorProtoFunc(exec, funcProto, toStringPropertyName), DontEnum);
+  put(exec, exec->propertyNames().name,     jsString("Error"), DontEnum);
+  put(exec, exec->propertyNames().message,  jsString("Unknown error"), DontEnum);
+  putDirectFunction(new ErrorProtoFunc(exec, funcProto, exec->propertyNames().toString), DontEnum);
 }
 
 // ------------------------------ ErrorProtoFunc ----------------------------
 
-ErrorProtoFunc::ErrorProtoFunc(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
+ErrorProtoFunc::ErrorProtoFunc(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
   : InternalFunctionImp(funcProto, name)
 {
-  putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete|ReadOnly|DontEnum);
 }
 
-JSValue *ErrorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
+JSValue* ErrorProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &/*args*/)
 {
   // toString()
   UString s = "Error";
 
-  JSValue *v = thisObj->get(exec, namePropertyName);
+  JSValue* v = thisObj->get(exec, exec->propertyNames().name);
   if (!v->isUndefined()) {
     s = v->toString(exec);
   }
 
-  v = thisObj->get(exec, messagePropertyName);
+  v = thisObj->get(exec, exec->propertyNames().message);
   if (!v->isUndefined()) {
     s += ": " + v->toString(exec); // Mozilla compatible format
   }
@@ -83,12 +81,12 @@ JSValue *ErrorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, cons
 
 // ------------------------------ ErrorObjectImp -------------------------------
 
-ErrorObjectImp::ErrorObjectImp(ExecState*, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
+ErrorObjectImp::ErrorObjectImp(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
   : InternalFunctionImp(funcProto)
 {
   // ECMA 15.11.3.1 Error.prototype
-  putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
-  putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().prototype, errorProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
   //putDirect(namePropertyName, jsString(n));
 }
 
@@ -98,14 +96,14 @@ bool ErrorObjectImp::implementsConstruct() const
 }
 
 // ECMA 15.9.3
-JSObject *ErrorObjectImp::construct(ExecState *exec, const List &args)
+JSObject* ErrorObjectImp::construct(ExecState* exec, const List &args)
 {
-  JSObject *proto = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinErrorPrototype());
-  JSObject *imp = new ErrorInstance(proto);
-  JSObject *obj(imp);
+  JSObject* proto = static_cast<JSObject*>(exec->lexicalInterpreter()->builtinErrorPrototype());
+  JSObjectimp = new ErrorInstance(proto);
+  JSObjectobj(imp);
 
   if (!args[0]->isUndefined())
-    imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
+    imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec)));
 
   return obj;
 }
@@ -119,24 +117,24 @@ JSValue *ErrorObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/,
 
 // ------------------------------ NativeErrorPrototype ----------------------
 
-NativeErrorPrototype::NativeErrorPrototype(ExecState*, ErrorPrototype* errorProto, ErrorType et, UString name, UString message)
+NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorProto, ErrorType et, UString name, UString message)
   : JSObject(errorProto)
 {
   errType = et;
-  putDirect(namePropertyName, jsString(name), 0);
-  putDirect(messagePropertyName, jsString(message), 0);
+  putDirect(exec->propertyNames().name, jsString(name), 0);
+  putDirect(exec->propertyNames().message, jsString(message), 0);
 }
 
 // ------------------------------ NativeErrorImp -------------------------------
 
 const ClassInfo NativeErrorImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
 
-NativeErrorImp::NativeErrorImp(ExecState*, FunctionPrototype* funcProto, JSObject* prot)
+NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, JSObject* prot)
   : InternalFunctionImp(funcProto)
   , proto(prot)
 {
-  putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
-  putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
+  putDirect(exec->propertyNames().prototype, proto, DontDelete|ReadOnly|DontEnum);
 }
 
 bool NativeErrorImp::implementsConstruct() const
@@ -144,18 +142,18 @@ bool NativeErrorImp::implementsConstruct() const
   return true;
 }
 
-JSObject *NativeErrorImp::construct(ExecState *exec, const List &args)
+JSObject* NativeErrorImp::construct(ExecState* exec, const List& args)
 {
-  JSObject *imp = new ErrorInstance(proto);
-  JSObject *obj(imp);
+  JSObjectimp = new ErrorInstance(proto);
+  JSObjectobj(imp);
   if (!args[0]->isUndefined())
-    imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
+    imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec)));
   return obj;
 }
 
-JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
+JSValue* NativeErrorImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
 {
-  return construct(exec,args);
+  return construct(exec, args);
 }
 
 void NativeErrorImp::mark()
index 581b649..68345f8 100644 (file)
@@ -262,18 +262,18 @@ JSValue* FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, con
 bool FunctionImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
     // Find the arguments from the closest context.
-    if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
+    if (propertyName == exec->propertyNames().arguments) {
         slot.setCustom(this, argumentsGetter);
         return true;
     }
 
     // Compute length of parameters.
-    if (propertyName == lengthPropertyName) {
+    if (propertyName == exec->propertyNames().length) {
         slot.setCustom(this, lengthGetter);
         return true;
     }
 
-    if (propertyName == callerPropertyName) {
+    if (propertyName == exec->propertyNames().caller) {
         slot.setCustom(this, callerGetter);
         return true;
     }
@@ -283,14 +283,14 @@ bool FunctionImp::getOwnPropertySlot(ExecState* exec, const Identifier& property
 
 void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
 {
-    if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
+    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
         return;
     InternalFunctionImp::put(exec, propertyName, value, attr);
 }
 
 bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
-    if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
+    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
         return false;
     return InternalFunctionImp::deleteProperty(exec, propertyName);
 }
@@ -305,17 +305,17 @@ bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName
 Identifier FunctionImp::getParameterName(int index)
 {
     if (!parameters)
-        return Identifier::null();
+        return CommonIdentifiers::shared()->nullIdentifier;
 
     if (static_cast<size_t>(index) >= parameters->size())
-        return Identifier::null();
+        return CommonIdentifiers::shared()->nullIdentifier;
   
     Identifier name = parameters->at(index).name;
 
     // Are there any subsequent parameters with the same name?
     for (size_t i = index + 1; i < parameters->size(); ++i)
         if (parameters->at(i).name == name)
-            return Identifier::null();
+            return CommonIdentifiers::shared()->nullIdentifier;
 
     return name;
 }
@@ -341,7 +341,7 @@ bool DeclaredFunctionImp::implementsConstruct() const
 JSObject* DeclaredFunctionImp::construct(ExecState* exec, const List& args)
 {
   JSObject* proto;
-  JSValue* p = get(exec,prototypePropertyName);
+  JSValue* p = get(exec, exec->propertyNames().prototype);
   if (p->isObject())
     proto = static_cast<JSObject*>(p);
   else
@@ -421,7 +421,7 @@ void IndexToNameMap::unMap(const Identifier& index)
 
   assert(indexIsNumber && indexAsNumber < size);
   
-  _map[indexAsNumber] = Identifier::null();
+  _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier;
 }
 
 Identifier& IndexToNameMap::operator[](int index)
@@ -449,8 +449,8 @@ Arguments::Arguments(ExecState* exec, FunctionImp* func, const List& args, Activ
 _activationObject(act),
 indexToNameMap(func, args)
 {
-  putDirect(calleePropertyName, func, DontEnum);
-  putDirect(lengthPropertyName, args.size(), DontEnum);
+  putDirect(exec->propertyNames().callee, func, DontEnum);
+  putDirect(exec->propertyNames().length, args.size(), DontEnum);
   
   int i = 0;
   ListIterator iterator = args.begin(); 
@@ -542,7 +542,7 @@ bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& proper
         return true;
     }
 
-    if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
+    if (propertyName == exec->propertyNames().arguments) {
         slot.setCustom(this, getArgumentsGetter());
         return true;
     }
@@ -552,7 +552,7 @@ bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& proper
 
 bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
-    if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier())
+    if (propertyName == exec->propertyNames().arguments)
         return false;
     return JSObject::deleteProperty(exec, propertyName);
 }
@@ -584,11 +584,11 @@ void ActivationImp::createArgumentsObject(ExecState* exec) const
 // ------------------------------ GlobalFunc -----------------------------------
 
 
-GlobalFuncImp::GlobalFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+GlobalFuncImp::GlobalFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
   : InternalFunctionImp(funcProto, name)
   , id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
 }
 
 CodeType GlobalFuncImp::codeType() const
index daf2700..f10f399 100644 (file)
@@ -43,8 +43,8 @@ FunctionPrototype::FunctionPrototype(ExecState *exec)
   static const Identifier* applyPropertyName = new Identifier("apply");
   static const Identifier* callPropertyName = new Identifier("call");
 
-  putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
-  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
+  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
   putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2, *applyPropertyName), DontEnum);
   putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1, *callPropertyName), DontEnum);
 }
@@ -61,16 +61,16 @@ JSValue *FunctionPrototype::callAsFunction(ExecState*, JSObject* /*thisObj*/, co
 
 // ------------------------------ FunctionProtoFunc -------------------------
 
-FunctionProtoFunc::FunctionProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+FunctionProtoFunc::FunctionProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
   : InternalFunctionImp(funcProto, name)
   , id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
 }
 
-JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* FunctionProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
 {
-  JSValue *result = NULL;
+  JSValueresult = NULL;
 
   switch (id) {
   case ToString:
@@ -113,7 +113,7 @@ JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, c
             static_cast<JSObject *>(argArray)->inherits(&Arguments::info))) {
 
         JSObject *argArrayObj = static_cast<JSObject *>(argArray);
-        unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec);
+        unsigned int length = argArrayObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
         for (unsigned int i = 0; i < length; i++)
           applyArgs.append(argArrayObj->get(exec,i));
       }
@@ -146,13 +146,13 @@ JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, c
 
 // ------------------------------ FunctionObjectImp ----------------------------
 
-FunctionObjectImp::FunctionObjectImp(ExecState*, FunctionPrototype* funcProto)
+FunctionObjectImp::FunctionObjectImp(ExecState* exec, FunctionPrototype* funcProto)
   : InternalFunctionImp(funcProto)
 {
-  putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, funcProto, DontEnum|DontDelete|ReadOnly);
 
   // no. of arguments for constructor
-  putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 FunctionObjectImp::~FunctionObjectImp()
@@ -243,10 +243,10 @@ JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args, const
   
   List consArgs;
 
-  JSObject *objCons = exec->lexicalInterpreter()->builtinObject();
-  JSObject *prototype = objCons->construct(exec,List::empty());
-  prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly);
-  fimp->put(exec, prototypePropertyName, prototype, Internal|DontDelete);
+  JSObjectobjCons = exec->lexicalInterpreter()->builtinObject();
+  JSObjectprototype = objCons->construct(exec,List::empty());
+  prototype->put(exec, exec->propertyNames().constructor, fimp, DontEnum|DontDelete|ReadOnly);
+  fimp->put(exec, exec->propertyNames().prototype, prototype, Internal|DontDelete);
   return fimp;
 }
 
index 20093e0..1dbb319 100644 (file)
@@ -32,7 +32,8 @@
 #include "nodes.h"
 #include "lexer.h"
 #include "internal.h"
-
+#include "CommonIdentifiers.h"
+    
 // Not sure why, but yacc doesn't add this define along with the others.
 #define yylloc kjsyylloc
 
@@ -815,7 +816,7 @@ ThrowStatement:
 ;
 
 TryStatement:
-    TRY Block FINALLY Block             { $$ = new TryNode($2, Identifier::null(), 0, $4); DBG($$, @1, @2); }
+TRY Block FINALLY Block             { $$ = new TryNode($2, CommonIdentifiers::shared()->nullIdentifier, 0, $4); DBG($$, @1, @2); }
   | TRY Block CATCH '(' IDENT ')' Block { $$ = new TryNode($2, *$5, $7, 0); DBG($$, @1, @2); }
   | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
                                         { $$ = new TryNode($2, *$5, $7, $9); DBG($$, @1, @2); }
@@ -833,9 +834,9 @@ FunctionDeclaration:
 ;
 
 FunctionExpr:
-    FUNCTION '(' ')' FunctionBody       { $$ = new FuncExprNode(Identifier::null(), $4); }
+    FUNCTION '(' ')' FunctionBody       { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $4); }
   | FUNCTION '(' FormalParameterList ')' FunctionBody
-                                        { $$ = new FuncExprNode(Identifier::null(), $5, $3); }
+                                        { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, $3); }
   | FUNCTION IDENT '(' ')' FunctionBody { $$ = new FuncExprNode(*$2, $5); }
   | FUNCTION IDENT '(' FormalParameterList ')' FunctionBody
                                         { $$ = new FuncExprNode(*$2, $6, $4); }
@@ -1001,7 +1002,7 @@ static bool makeGetterOrSetterPropertyNode(PropertyNode*& result, Identifier& ge
         return false;
     
     result = new PropertyNode(new PropertyNameNode(name), 
-                              new FuncExprNode(Identifier::null(), body, params), type);
+                              new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, params), type);
 
     return true;
 }
index 115760c..30a51be 100644 (file)
  */
 
 #include "config.h"
-// For JavaScriptCore we need to avoid having static constructors.
-// Our strategy is to declare the global objects with a different type (initialized to 0)
-// and then use placement new to initialize the global objects later. This is not completely
-// portable, and it would be good to figure out a 100% clean way that still avoids code that
-// runs at init time.
-
-#if !PLATFORM(WIN_OS) // can't get this to compile on Visual C++ yet
-#define AVOID_STATIC_CONSTRUCTORS 1
-#else
-#define AVOID_STATIC_CONSTRUCTORS 0
-#endif
-
-#if AVOID_STATIC_CONSTRUCTORS
-#define KJS_IDENTIFIER_HIDE_GLOBALS 1
-#endif
 
 #include "identifier.h"
 
@@ -209,42 +194,4 @@ void Identifier::remove(UString::Rep *r)
     identifierTable().remove(r);
 }
 
-// Global constants for property name strings.
-
-#if !AVOID_STATIC_CONSTRUCTORS
-    // Define an Identifier in the normal way.
-    #define DEFINE_GLOBAL(name, string) extern const Identifier name(string);
-#else
-    // Define an Identifier-sized array of pointers to avoid static initialization.
-    // Use an array of pointers instead of an array of char in case there is some alignment issue.
-    #define DEFINE_GLOBAL(name, string) \
-        void * name[(sizeof(Identifier) + sizeof(void *) - 1) / sizeof(void *)];
-#endif
-
-const char * const nullCString = 0;
-
-DEFINE_GLOBAL(nullIdentifier, nullCString)
-DEFINE_GLOBAL(specialPrototypePropertyName, "__proto__")
-
-#define DEFINE_PROPERTY_NAME_GLOBAL(name) DEFINE_GLOBAL(name ## PropertyName, #name)
-KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(DEFINE_PROPERTY_NAME_GLOBAL)
-
-void Identifier::init()
-{
-#if AVOID_STATIC_CONSTRUCTORS
-    static bool initialized;
-    if (!initialized) {
-        // Use placement new to initialize the globals.
-
-        new (&nullIdentifier) Identifier(nullCString);
-        new (&specialPrototypePropertyName) Identifier("__proto__");
-
-        #define PLACEMENT_NEW_PROPERTY_NAME_GLOBAL(name) new(&name ## PropertyName) Identifier(#name);
-        KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(PLACEMENT_NEW_PROPERTY_NAME_GLOBAL)
-
-        initialized = true;
-    }
-#endif
-}
-
 } // namespace KJS
index 1083da3..7f267ff 100644 (file)
@@ -29,8 +29,6 @@ namespace KJS {
     class Identifier {
         friend class PropertyMap;
     public:
-        static void init();
-
         Identifier() { }
         Identifier(const char* s) : _ustring(add(s)) { }
         Identifier(const UChar* s, int length) : _ustring(add(s, length)) { }
@@ -56,8 +54,6 @@ namespace KJS {
         unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); }
         double toDouble() const { return _ustring.toDouble(); }
         
-        static const Identifier& null();
-        
         friend bool operator==(const Identifier&, const Identifier&);
         friend bool operator!=(const Identifier&, const Identifier&);
 
@@ -82,13 +78,6 @@ namespace KJS {
         static PassRefPtr<UString::Rep> add(UString::Rep*);
     };
     
-#ifndef KJS_IDENTIFIER_HIDE_GLOBALS
-    extern const Identifier nullIdentifier;
-
-    inline const Identifier& Identifier::null()
-        { return nullIdentifier; }
-#endif
-
     inline bool operator==(const Identifier& a, const Identifier& b)
         { return Identifier::equal(a, b); }
 
@@ -98,34 +87,6 @@ namespace KJS {
     inline bool operator==(const Identifier& a, const char* b)
         { return Identifier::equal(a, b); }
 
-    // List of property names, passed to a macro so we can do set them up various
-    // ways without repeating the list.
-    #define KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(macro) \
-        macro(arguments) \
-        macro(callee) \
-        macro(caller) \
-        macro(constructor) \
-        macro(fromCharCode) \
-        macro(length) \
-        macro(message) \
-        macro(name) \
-        macro(prototype) \
-        macro(toLocaleString) \
-        macro(toString) \
-        macro(toFixed) \
-        macro(toExponential) \
-        macro(toPrecision) \
-        macro(valueOf)
-
-    // Define external global variables for all property names above (and one more).
-#ifndef KJS_IDENTIFIER_HIDE_GLOBALS
-    extern const Identifier specialPrototypePropertyName;
-
-    #define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) extern const Identifier name ## PropertyName;
-    KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
-    #undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
-#endif
-
 } // namespace KJS
 
 #endif // KJS_IDENTIFIER_H
index 066397c..9464483 100644 (file)
@@ -96,8 +96,6 @@ void Interpreter::init()
 {
     JSLock lock;
 
-    Identifier::init();
-
     m_refCount = 0;
     m_timeoutTime = 0;
     m_recursion = 0;
@@ -108,8 +106,6 @@ void Interpreter::init()
     m_timeoutCheckCount = 0;
     
     m_compatMode = NativeMode;
-    m_argumentsPropertyName = &argumentsPropertyName;
-    m_specialPrototypePropertyName = &specialPrototypePropertyName;
 
     if (s_hook) {
         prev = s_hook;
@@ -227,22 +223,22 @@ void Interpreter::initGlobalObject()
     m_TypeError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_TypeErrorPrototype);
     m_UriError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_UriErrorPrototype);
     
-    m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum);
-    m_ObjectPrototype->put(&m_globalExec, constructorPropertyName, m_Object, DontEnum | DontDelete | ReadOnly);
-    m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum | DontDelete | ReadOnly);
-    m_ArrayPrototype->put(&m_globalExec, constructorPropertyName, m_Array, DontEnum | DontDelete | ReadOnly);
-    m_BooleanPrototype->put(&m_globalExec, constructorPropertyName, m_Boolean, DontEnum | DontDelete | ReadOnly);
-    m_StringPrototype->put(&m_globalExec, constructorPropertyName, m_String, DontEnum | DontDelete | ReadOnly);
-    m_NumberPrototype->put(&m_globalExec, constructorPropertyName, m_Number, DontEnum | DontDelete | ReadOnly);
-    m_DatePrototype->put(&m_globalExec, constructorPropertyName, m_Date, DontEnum | DontDelete | ReadOnly);
-    m_RegExpPrototype->put(&m_globalExec, constructorPropertyName, m_RegExp, DontEnum | DontDelete | ReadOnly);
-    m_ErrorPrototype->put(&m_globalExec, constructorPropertyName, m_Error, DontEnum | DontDelete | ReadOnly);
-    m_EvalErrorPrototype->put(&m_globalExec, constructorPropertyName, m_EvalError, DontEnum | DontDelete | ReadOnly);
-    m_RangeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_RangeError, DontEnum | DontDelete | ReadOnly);
-    m_ReferenceErrorPrototype->put(&m_globalExec, constructorPropertyName, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
-    m_SyntaxErrorPrototype->put(&m_globalExec, constructorPropertyName, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
-    m_TypeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_TypeError, DontEnum | DontDelete | ReadOnly);
-    m_UriErrorPrototype->put(&m_globalExec, constructorPropertyName, m_UriError, DontEnum | DontDelete | ReadOnly);
+    m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum);
+    m_ObjectPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Object, DontEnum | DontDelete | ReadOnly);
+    m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum | DontDelete | ReadOnly);
+    m_ArrayPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Array, DontEnum | DontDelete | ReadOnly);
+    m_BooleanPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Boolean, DontEnum | DontDelete | ReadOnly);
+    m_StringPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_String, DontEnum | DontDelete | ReadOnly);
+    m_NumberPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Number, DontEnum | DontDelete | ReadOnly);
+    m_DatePrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Date, DontEnum | DontDelete | ReadOnly);
+    m_RegExpPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RegExp, DontEnum | DontDelete | ReadOnly);
+    m_ErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Error, DontEnum | DontDelete | ReadOnly);
+    m_EvalErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_EvalError, DontEnum | DontDelete | ReadOnly);
+    m_RangeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RangeError, DontEnum | DontDelete | ReadOnly);
+    m_ReferenceErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
+    m_SyntaxErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
+    m_TypeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_TypeError, DontEnum | DontDelete | ReadOnly);
+    m_UriErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_UriError, DontEnum | DontDelete | ReadOnly);
 
     // Set global object prototype
     JSObject* o = m_globalObject;
index d608281..db4f10b 100644 (file)
@@ -327,11 +327,6 @@ namespace KJS {
      */
     virtual bool isSafeScript(const Interpreter*) { return true; }
   
-    // This is a workaround to avoid accessing the global variables for these identifiers in
-    // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
-    const Identifier& argumentsIdentifier() { return *m_argumentsPropertyName; }
-    const Identifier& specialPrototypeIdentifier() { return *m_specialPrototypePropertyName; }
-    
     // Chained list of interpreters (ring)
     static Interpreter* firstInterpreter() { return s_hook; }
     Interpreter* nextInterpreter() const { return next; }
@@ -376,9 +371,6 @@ private:
     
     ExecState m_globalExec;
 
-    const Identifier *m_argumentsPropertyName;
-    const Identifier *m_specialPrototypePropertyName;
-
     // Chained list of interpreters (ring) - for collector
     static Interpreter* s_hook;
     Interpreter *next, *prev;
index e09055f..9b1aa35 100644 (file)
@@ -352,7 +352,7 @@ namespace KJS {
       : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \
       , id(i) \
     { \
-       put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
+       put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
     } \
     /* Macro user needs to implement the callAsFunction function. */ \
     virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List& args); \
index e7c7ffe..72ab987 100644 (file)
@@ -121,7 +121,7 @@ MathFuncImp::MathFuncImp(ExecState* exec, int i, int l, const Identifier& name)
   : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
   , id(i)
 {
-  putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, l, DontDelete|ReadOnly|DontEnum);
 }
 
 JSValue *MathFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
index d696b4d..4746f4e 100644 (file)
@@ -445,7 +445,7 @@ JSValue *ArrayNode::evaluate(ExecState *exec)
   if (element) {
     array = static_cast<JSObject*>(element->evaluate(exec));
     KJS_CHECKEXCEPTIONVALUE
-    length = opt ? array->get(exec,lengthPropertyName)->toInt32(exec) : 0;
+    length = opt ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0;
   } else {
     JSValue *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
     array = static_cast<JSObject*>(newArr);
@@ -453,7 +453,7 @@ JSValue *ArrayNode::evaluate(ExecState *exec)
   }
 
   if (opt)
-    array->put(exec,lengthPropertyName, jsNumber(elision + length), DontEnum | DontDelete);
+    array->put(exec, exec->propertyNames().length, jsNumber(elision + length), DontEnum | DontDelete);
 
   return array;
 }
@@ -2369,14 +2369,14 @@ void FuncDeclNode::processFuncDecl(ExecState *exec)
   FunctionImp *func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
 
   JSObject *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
-  proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
-  func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
+  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
+  func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete);
 
   int plen = 0;
   for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
     func->addParameter(p->ident());
 
-  func->put(exec, lengthPropertyName, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
+  func->put(exec, exec->propertyNames().length, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
 
   // ECMA 10.2.2
   context->variableObject()->put(exec, ident, func, Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
@@ -2415,10 +2415,10 @@ JSValue *FuncExprNode::evaluate(ExecState *exec)
     context->pushScope(functionScopeObject);
   }
 
-  FunctionImp *func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
-  JSObject *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
-  proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
-  func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
+  FunctionImpfunc = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
+  JSObjectproto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
+  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
+  func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete);
 
   int plen = 0;
   for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
index c430dd1..0e3e894 100644 (file)
@@ -52,22 +52,22 @@ NumberPrototype::NumberPrototype(ExecState *exec,
 
   // The constructor will be added later, after NumberObjectImp has been constructed
 
-  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString,       1, toStringPropertyName), DontEnum);
-  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
-  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf,        0, valueOfPropertyName), DontEnum);
-  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed,        1, toFixedPropertyName), DontEnum);
-  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential,  1, toExponentialPropertyName), DontEnum);
-  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision,    1, toPrecisionPropertyName), DontEnum);
+  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString,       1, exec->propertyNames().toString), DontEnum);
+  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, exec->propertyNames().toLocaleString), DontEnum);
+  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf,        0, exec->propertyNames().valueOf), DontEnum);
+  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed,        1, exec->propertyNames().toFixed), DontEnum);
+  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential,  1, exec->propertyNames().toExponential), DontEnum);
+  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision,    1, exec->propertyNames().toPrecision), DontEnum);
 }
 
 
 // ------------------------------ NumberProtoFunc ---------------------------
 
-NumberProtoFunc::NumberProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+NumberProtoFunc::NumberProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    : InternalFunctionImp(funcProto, name)
    , id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
 }
 
 static UString integer_part_noexp(double d)
@@ -416,14 +416,14 @@ const ClassInfo NumberObjectImp::info = {"Function", &InternalFunctionImp::info,
   MIN_VALUE             NumberObjectImp::MinValue       DontEnum|DontDelete|ReadOnly
 @end
 */
-NumberObjectImp::NumberObjectImp(ExecState*, FunctionPrototype* funcProto, NumberPrototype* numberProto)
+NumberObjectImp::NumberObjectImp(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto)
   : InternalFunctionImp(funcProto)
 {
   // Number.Prototype
-  putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, numberProto,DontEnum|DontDelete|ReadOnly);
 
   // no. of arguments for constructor
-  putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 bool NumberObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index 9893566..02c921c 100644 (file)
@@ -205,12 +205,12 @@ static void throwSetterError(ExecState *exec)
 }
 
 // ECMA 8.6.2.2
-void JSObject::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void JSObject::put(ExecStateexec, const Identifier &propertyName, JSValue *value, int attr)
 {
   assert(value);
 
   // non-standard netscape extension
-  if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
+  if (propertyName == exec->propertyNames().underscoreProto) {
     setPrototype(value);
     return;
   }
@@ -353,17 +353,17 @@ static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObj
 }
 
 // ECMA 8.6.2.6
-JSValue *JSObject::defaultValue(ExecState *exec, JSType hint) const
+JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
 {
   Identifier firstPropertyName;
   Identifier secondPropertyName;
   /* Prefer String for Date objects */
   if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) {
-    firstPropertyName = toStringPropertyName;
-    secondPropertyName = valueOfPropertyName;
+    firstPropertyName = exec->propertyNames().toString;
+    secondPropertyName = exec->propertyNames().valueOf;
   } else {
-    firstPropertyName = valueOfPropertyName;
-    secondPropertyName = toStringPropertyName;
+    firstPropertyName = exec->propertyNames().valueOf;
+    secondPropertyName = exec->propertyNames().toString;
   }
 
   JSValue *v;
@@ -455,7 +455,7 @@ bool JSObject::implementsHasInstance() const
 
 bool JSObject::hasInstance(ExecState* exec, JSValue* value)
 {
-    JSValue* proto = get(exec, prototypePropertyName);
+    JSValue* proto = get(exec, exec->propertyNames().prototype);
     if (!proto->isObject()) {
         throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property.");
         return false;
index 0a2e49b..8dfa054 100644 (file)
@@ -26,6 +26,7 @@
 #define KJS_OBJECT_H
 
 #include "JSType.h"
+#include "CommonIdentifiers.h"
 #include "interpreter.h"
 #include "property_map.h"
 #include "property_slot.h"
@@ -245,8 +246,8 @@ namespace KJS {
      * @param propertyName The name of the property to set
      * @param propertyValue The value to set
      */
-    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, int attr = None);
+    virtual void put(ExecState* exec, unsigned propertyName, JSValue* value, int attr = None);
 
     /**
      * Used to check whether or not a particular property is allowed to be set
@@ -564,7 +565,7 @@ inline bool JSObject::getPropertySlot(ExecState *exec, const Identifier& propert
 // It may seem crazy to inline a function this large, especially a virtual function,
 // but it makes a big difference to property lookup that derived classes can inline their
 // base class call to this.
-ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecStateexec, const Identifier& propertyName, PropertySlot& slot)
 {
     if (JSValue **location = getDirectLocation(propertyName)) {
         if (_prop.hasGetterSetterProperties() && location[0]->type() == GetterSetterType)
@@ -575,7 +576,7 @@ ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifie
     }
 
     // non-standard Netscape extension
-    if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
+    if (propertyName == exec->propertyNames().underscoreProto) {
         slot.setValueSlot(this, &_proto);
         return true;
     }
index e879ae0..10a91cd 100644 (file)
@@ -41,9 +41,9 @@ ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* funcProto)
     static const Identifier* lookupGetterPropertyName = new Identifier("__lookupGetter__");
     static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__");
 
-    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
-    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
-    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, valueOfPropertyName), DontEnum);
+    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
+    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, exec->propertyNames().toLocaleString), DontEnum);
+    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, exec->propertyNames().valueOf), DontEnum);
     putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::HasOwnProperty, 1, *hasOwnPropertyPropertyName), DontEnum);
     putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::PropertyIsEnumerable, 1, *propertyIsEnumerablePropertyName), DontEnum);
     putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::IsPrototypeOf, 1, *isPrototypeOfPropertyName), DontEnum);
@@ -58,11 +58,11 @@ ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* funcProto)
 
 // ------------------------------ ObjectProtoFunc --------------------------------
 
-ObjectProtoFunc::ObjectProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+ObjectProtoFunc::ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
   : InternalFunctionImp(funcProto, name)
   , id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
 }
 
 
@@ -152,14 +152,14 @@ JSValue *ObjectProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, con
 
 // ------------------------------ ObjectObjectImp --------------------------------
 
-ObjectObjectImp::ObjectObjectImp(ExecState*, ObjectPrototype* objProto, FunctionPrototype* funcProto)
+ObjectObjectImp::ObjectObjectImp(ExecState* exec, ObjectPrototype* objProto, FunctionPrototype* funcProto)
   : InternalFunctionImp(funcProto)
 {
   // ECMA 15.2.3.1
-  putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly);
 
   // no. of arguments for constructor
-  putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 
index 23d3638..a354a97 100644 (file)
@@ -53,15 +53,15 @@ RegExpPrototype::RegExpPrototype(ExecState *exec,
 
   putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Exec, 0, *execPropertyName), DontEnum);
   putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Test, 0, *testPropertyName), DontEnum);
-  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
+  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
 }
 
 // ------------------------------ RegExpProtoFunc ---------------------------
 
-RegExpProtoFunc::RegExpProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+RegExpProtoFunc::RegExpProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    : InternalFunctionImp(funcProto, name), id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
 }
 
 JSValue *RegExpProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
@@ -180,15 +180,15 @@ const ClassInfo RegExpObjectImp::info = {"Function", &InternalFunctionImp::info,
 @end
 */
 
-RegExpObjectImp::RegExpObjectImp(ExecState*, FunctionPrototype* funcProto, RegExpPrototype* regProto)
+RegExpObjectImp::RegExpObjectImp(ExecState* exec, FunctionPrototype* funcProto, RegExpPrototype* regProto)
 
   : InternalFunctionImp(funcProto), lastInput(""), lastNumSubPatterns(0), multiline(false)
 {
   // ECMA 15.10.5.1 RegExp.prototype
-  putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, regProto, DontEnum | DontDelete | ReadOnly);
 
   // no. of arguments for constructor
-  putDirect(lengthPropertyName, jsNumber(2), ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
 }
 
 /* 
index ae86198..d309239 100644 (file)
@@ -70,7 +70,7 @@ JSValue *StringInstance::indexGetter(ExecState* exec, JSObject*, const Identifie
 
 bool StringInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
 {
-  if (propertyName == lengthPropertyName) {
+  if (propertyName == exec->propertyNames().length) {
     slot.setCustom(this, lengthGetter);
     return true;
   }
@@ -91,14 +91,14 @@ bool StringInstance::getOwnPropertySlot(ExecState *exec, const Identifier& prope
 
 void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
 {
-  if (propertyName == lengthPropertyName)
+  if (propertyName == exec->propertyNames().length)
     return;
   JSObject::put(exec, propertyName, value, attr);
 }
 
 bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
 {
-  if (propertyName == lengthPropertyName)
+  if (propertyName == exec->propertyNames().length)
     return false;
   return JSObject::deleteProperty(exec, propertyName);
 }
@@ -154,11 +154,11 @@ const ClassInfo StringPrototype::info = {"String", &StringInstance::info, &strin
 @end
 */
 // ECMA 15.5.4
-StringPrototype::StringPrototype(ExecState*, ObjectPrototype* objProto)
+StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto)
   : StringInstance(objProto)
 {
   // The constructor will be added later, after StringObjectImp has been built
-  putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
 }
 
 bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
@@ -168,11 +168,11 @@ bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& prop
 
 // ------------------------------ StringProtoFunc ---------------------------
 
-StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
+StringProtoFunc::StringProtoFunc(ExecStateexec, int i, int len, const Identifier& name)
   : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
   , id(i)
 {
-  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
 }
 
 static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity)
@@ -418,9 +418,9 @@ static JSValue *replace(ExecState *exec, const UString &source, JSValue *pattern
 }
 
 // ECMA 15.5.4.2 - 15.5.4.20
-JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* StringProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
 {
-  JSValue *result = NULL;
+  JSValueresult = NULL;
 
   // toString and valueOf are no generic function.
   if (id == ToString || id == ValueOf) {
@@ -590,7 +590,7 @@ JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, con
       RegExp *reg = static_cast<RegExpImp *>(a0)->regExp();
       if (u.isEmpty() && !reg->match(u, 0).isNull()) {
         // empty string matched by regexp -> empty array
-        res->put(exec,lengthPropertyName, jsNumber(0));
+        res->put(exec, exec->propertyNames().length, jsNumber(0));
         break;
       }
       pos = 0;
@@ -614,7 +614,7 @@ JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, con
       if (u2.isEmpty()) {
         if (u.isEmpty()) {
           // empty separator matches empty string -> empty array
-          put(exec,lengthPropertyName, jsNumber(0));
+          put(exec, exec->propertyNames().length, jsNumber(0));
           break;
         } else {
           while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
@@ -631,7 +631,7 @@ JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, con
     // add remaining string, if any
     if (static_cast<uint32_t>(i) != limit)
       res->put(exec, i++, jsString(u.substr(p0)));
-    res->put(exec,lengthPropertyName, jsNumber(i));
+    res->put(exec, exec->propertyNames().length, jsNumber(i));
     }
     break;
   case Substr: {
@@ -760,18 +760,18 @@ JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, con
 
 // ------------------------------ StringObjectImp ------------------------------
 
-StringObjectImp::StringObjectImp(ExecState *exec,
-                                 FunctionPrototype *funcProto,
-                                 StringPrototype *stringProto)
+StringObjectImp::StringObjectImp(ExecStateexec,
+                                 FunctionPrototypefuncProto,
+                                 StringPrototypestringProto)
   : InternalFunctionImp(funcProto)
 {
   // ECMA 15.5.3.1 String.prototype
-  putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
+  putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly);
 
-  putDirectFunction(new StringObjectFuncImp(exec, funcProto, fromCharCodePropertyName), DontEnum);
+  putDirectFunction(new StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
 
   // no. of arguments for constructor
-  putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 
@@ -803,10 +803,10 @@ JSValue *StringObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/,
 // ------------------------------ StringObjectFuncImp --------------------------
 
 // ECMA 15.5.3.2 fromCharCode()
-StringObjectFuncImp::StringObjectFuncImp(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
+StringObjectFuncImp::StringObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
   : InternalFunctionImp(funcProto, name)
 {
-  putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
+  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
 }
 
 JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
index b3bd6e8..daef219 100644 (file)
@@ -118,7 +118,7 @@ private:
 
 TestFunctionImp::TestFunctionImp(int i, int length) : JSObject(), id(i)
 {
-  putDirect(lengthPropertyName,length,DontDelete|ReadOnly|DontEnum);
+  putDirect(Identifier("length"), length, DontDelete | ReadOnly | DontEnum);
 }
 
 JSValue* TestFunctionImp::callAsFunction(ExecState* exec, JSObject*, const List &args)
index 0f0928d..e381a3f 100644 (file)
@@ -1,3 +1,33 @@
+2007-03-18  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Mark.
+
+        - avoid static construction (and global variable access) in a smarter, more portable way,
+        to later enable MUTLI_THREAD mode to work on other platforms and compilers.
+        
+        * bindings/js/JSCustomXPathNSResolver.cpp:
+        (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
+        * bindings/js/JSHTMLInputElementBase.cpp:
+        (WebCore::JSHTMLInputElementBaseFunction::JSHTMLInputElementBaseFunction):
+        * bindings/js/JSHTMLOptionElementConstructor.cpp:
+        (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
+        * bindings/js/JSXMLHttpRequest.cpp:
+        (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp):
+        * bindings/js/JSXSLTProcessor.cpp:
+        (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
+        * bindings/js/kjs_dom.cpp:
+        (KJS::DOMNamedNodeMap::getOwnPropertySlot):
+        (KJS::DOMNamedNodesCollection::getOwnPropertySlot):
+        * bindings/js/kjs_events.cpp:
+        (KJS::JSAbstractEventListener::handleEvent):
+        * bindings/js/kjs_html.cpp:
+        (KJS::HTMLElementFunction::HTMLElementFunction):
+        (KJS::JSHTMLCollection::getOwnPropertySlot):
+        * bindings/js/kjs_window.cpp:
+        (KJS::ScheduledAction::execute):
+        * bindings/objc/WebScriptObject.mm:
+        * bindings/scripts/CodeGeneratorJS.pm:
+
 2007-03-18  Andrew Wellington  <proton@wiretapped.net>
 
         Reviewed by Mark Rowe
index 6dc0934..82397d9 100644 (file)
@@ -112,7 +112,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
 
     if (exec->hadException()) {
         JSObject* exception = exec->exception()->toObject(exec);
-        String message = exception->get(exec, messagePropertyName)->toString(exec);
+        String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
         int lineNumber = exception->get(exec, "line")->toInt32(exec);
         String sourceURL = exception->get(exec, "sourceURL")->toString(exec);
         if (Interpreter::shouldPrintExceptions())
index 85c4613..825cc6a 100644 (file)
@@ -62,7 +62,7 @@ JSHTMLInputElementBaseFunction::JSHTMLInputElementBaseFunction(ExecState* exec,
     : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
     , m_id(i)
 {
-    put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum);
+    put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum);
 }
 
 JSValue* JSHTMLInputElementBaseFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
index 22879ce..b1043d5 100644 (file)
@@ -33,7 +33,7 @@ JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec,
     : m_doc(d)
 {
     setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
-    put(exec, lengthPropertyName, jsNumber(4), ReadOnly|DontDelete|DontEnum);
+    put(exec, exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
 }
 
 bool JSHTMLOptionElementConstructor::implementsConstruct() const
index 5abb934..b9bb030 100644 (file)
@@ -60,7 +60,7 @@ JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp(ExecState* exec,
     : doc(d)
 {
     setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
-    putDirect(prototypePropertyName, JSXMLHttpRequestPrototype::self(exec), None);
+    putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None);
 }
 
 bool JSXMLHttpRequestConstructorImp::implementsConstruct() const
index 5cc1d06..cb4cdc5 100644 (file)
@@ -154,7 +154,7 @@ JSValue *XSLTProcessorPrototypeFunction::callAsFunction(ExecState *exec, JSObjec
 XSLTProcessorConstructorImp::XSLTProcessorConstructorImp(ExecState *exec)
 {
     setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
-    putDirect(prototypePropertyName, XSLTProcessorPrototype::self(exec), None);
+    putDirect(exec->propertyNames().prototype, XSLTProcessorPrototype::self(exec), None);
 }
 
 }
index 81038fd..457e4b5 100644 (file)
@@ -861,7 +861,7 @@ JSValue* DOMNamedNodeMap::nameGetter(ExecState* exec, JSObject* originalObject,
 
 bool DOMNamedNodeMap::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
-  if (propertyName == lengthPropertyName) {
+  if (propertyName == exec->propertyNames().length) {
       slot.setCustom(this, lengthGetter);
       return true;
   } else {
@@ -1148,7 +1148,7 @@ JSValue* DOMNamedNodesCollection::indexGetter(ExecState* exec, JSObject* origina
 
 bool DOMNamedNodesCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
-  if (propertyName == lengthPropertyName) {
+  if (propertyName == exec->propertyNames().length) {
     slot.setCustom(this, lengthGetter);
     return true;
   }
index 281fada..6f90c65 100644 (file)
@@ -129,7 +129,7 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
 
         if (exec->hadException()) {
             JSObject* exception = exec->exception()->toObject(exec);
-            String message = exception->get(exec, messagePropertyName)->toString(exec);
+            String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
             int lineNumber = exception->get(exec, "line")->toInt32(exec);
             String sourceURL = exception->get(exec, "sourceURL")->toString(exec);
             if (Interpreter::shouldPrintExceptions())
index 92571fb..f1768aa 100644 (file)
@@ -1072,7 +1072,7 @@ HTMLElementFunction::HTMLElementFunction(ExecState* exec, int i, int len, const
   : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
   , id(i)
 {
-  put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
+  put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
 }
 
 JSValue *HTMLElementFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
@@ -1473,7 +1473,7 @@ JSValue *JSHTMLCollection::nameGetter(ExecState* exec, JSObject* originalObject,
 
 bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
-  if (propertyName == lengthPropertyName) {
+  if (propertyName == exec->propertyNames().length) {
       slot.setCustom(this, lengthGetter);
       return true;
   } else {
index b20cdfe..392fa91 100644 (file)
@@ -1883,7 +1883,7 @@ void ScheduledAction::execute(Window* window)
             if (exec->hadException()) {
                 JSObject* exception = exec->exception()->toObject(exec);
                 exec->clearException();
-                String message = exception->get(exec, messagePropertyName)->toString(exec);
+                String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
                 int lineNumber = exception->get(exec, "line")->toInt32(exec);
                 if (Interpreter::shouldPrintExceptions())
                     printf("(timer):%s\n", message.utf8().data());
index 725755d..0b30505 100644 (file)
@@ -37,7 +37,7 @@ using namespace KJS::Bindings;
 
 #define LOG_EXCEPTION(exec) \
     if (Interpreter::shouldPrintExceptions()) \
-        printf("%s:%d:[%d]  JavaScript exception:  %s\n", __FILE__, __LINE__, getpid(), exec->exception()->toObject(exec)->get(exec, messagePropertyName)->toString(exec).ascii());
+        printf("%s:%d:[%d]  JavaScript exception:  %s\n", __FILE__, __LINE__, getpid(), exec->exception()->toObject(exec)->get(exec, exec->propertyNames().message)->toString(exec).ascii());
 
 @implementation WebScriptObjectPrivate
 
index 202c886..23b9ad3 100644 (file)
@@ -1654,7 +1654,7 @@ public:
     ${className}Constructor(ExecState* exec)
     {
         setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
-        putDirect(prototypePropertyName, ${protoClassName}::self(exec), None);
+        putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec), None);
     }
     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     JSValue* getValueProperty(ExecState*, int token) const;
@@ -1703,7 +1703,7 @@ public:
         : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
         , id(i)
     {
-        put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum);
+        put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum);
     }
     virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List& args);
 private: