Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jun 2008 06:03:24 +0000 (06:03 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jun 2008 06:03:24 +0000 (06:03 +0000)
        Combine per-thread objects into one, to make it easier to support legacy clients (for
        which they shouldn't be really per-thread).

        No change on SunSpider total.

        * JavaScriptCore.xcodeproj/project.pbxproj: Added JSGlobalData.{h,cpp}

        * kjs/JSGlobalData.cpp: Added.
        (KJS::JSGlobalData::JSGlobalData):
        (KJS::JSGlobalData::~JSGlobalData):
        (KJS::JSGlobalData::threadInstance):
        * kjs/JSGlobalData.h: Added.
        This class encapsulates all data that should be per-thread (or shared between legacy clients).
        It will also keep a Heap pointer, but right now, Heap (Collector) methods are all static.

        * kjs/identifier.h:
        (KJS::Identifier::Identifier):
        Added a constructor explicitly taking JSGlobalData to access IdentifierTable. Actually,
        all of them should, but this will be a separate patch.

        * kjs/identifier.cpp:
        (KJS::IdentifierTable::literalTable):
        (KJS::createIdentifierTable):
        (KJS::deleteIdentifierTable):
        (KJS::Identifier::add):
        (KJS::Identifier::addSlowCase):
        Combined IdentifierTable and LiteralIdentifierTable into a single class for simplicity.

        * kjs/grammar.y: kjsyyparse now takes JSGlobalData, not just a Lexer.

        * kjs/nodes.cpp:
        (KJS::Node::Node):
        (KJS::EvalFunctionCallNode::emitCode):
        (KJS::ScopeNode::ScopeNode):
        Changed to access Lexer and Parser via JSGlobalData::threadInstance(). This is also a
        temporary measure, they will need to use JSGlobalData explicitly.

        * VM/CodeGenerator.cpp:
        (KJS::CodeGenerator::CodeGenerator):
        * VM/CodeGenerator.h:
        * VM/Machine.cpp:
        (KJS::callEval):
        * kjs/CommonIdentifiers.cpp:
        (KJS::CommonIdentifiers::CommonIdentifiers):
        * kjs/CommonIdentifiers.h:
        * kjs/DebuggerCallFrame.cpp:
        (KJS::DebuggerCallFrame::evaluate):
        * kjs/ExecState.cpp:
        (KJS::ExecState::ExecState):
        * kjs/ExecState.h:
        (KJS::ExecState::globalData):
        (KJS::ExecState::identifierTable):
        (KJS::ExecState::propertyNames):
        (KJS::ExecState::emptyList):
        (KJS::ExecState::lexer):
        (KJS::ExecState::parser):
        (KJS::ExecState::arrayTable):
        (KJS::ExecState::dateTable):
        (KJS::ExecState::mathTable):
        (KJS::ExecState::numberTable):
        (KJS::ExecState::RegExpImpTable):
        (KJS::ExecState::RegExpObjectImpTable):
        (KJS::ExecState::stringTable):
        * kjs/InitializeThreading.cpp:
        (KJS::initializeThreadingOnce):
        * kjs/JSGlobalObject.cpp:
        (KJS::JSGlobalObject::init):
        * kjs/JSGlobalObject.h:
        (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
        (KJS::JSGlobalObject::head):
        (KJS::JSGlobalObject::globalData):
        * kjs/Parser.cpp:
        (KJS::Parser::parse):
        * kjs/Parser.h:
        * kjs/function.cpp:
        (KJS::FunctionImp::getParameterName):
        (KJS::IndexToNameMap::unMap):
        (KJS::globalFuncEval):
        * kjs/function_object.cpp:
        (KJS::FunctionObjectImp::construct):
        * kjs/interpreter.cpp:
        (KJS::Interpreter::checkSyntax):
        (KJS::Interpreter::evaluate):
        * kjs/lexer.cpp:
        (kjsyylex):
        * kjs/lexer.h:
        * kjs/testkjs.cpp:
        (prettyPrintScript):
        Updated for the above changes. Most of threadInstance uses here will need to be replaced with
        explicitly passed pointers to support legacy JSC clients.

        * JavaScriptCore.exp: Removed KJS::parser().

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

28 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/VM/CodeGenerator.cpp
JavaScriptCore/VM/CodeGenerator.h
JavaScriptCore/VM/Machine.cpp
JavaScriptCore/kjs/CommonIdentifiers.cpp
JavaScriptCore/kjs/CommonIdentifiers.h
JavaScriptCore/kjs/DebuggerCallFrame.cpp
JavaScriptCore/kjs/ExecState.cpp
JavaScriptCore/kjs/ExecState.h
JavaScriptCore/kjs/InitializeThreading.cpp
JavaScriptCore/kjs/JSGlobalData.cpp [new file with mode: 0644]
JavaScriptCore/kjs/JSGlobalData.h [new file with mode: 0644]
JavaScriptCore/kjs/JSGlobalObject.cpp
JavaScriptCore/kjs/JSGlobalObject.h
JavaScriptCore/kjs/Parser.cpp
JavaScriptCore/kjs/Parser.h
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/lexer.cpp
JavaScriptCore/kjs/lexer.h
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/testkjs.cpp

index b755c7f160f56196a9c2bf6bc58e14784861a2fa..65a038e6dd5b23ebdd77978183c77c19624cf05b 100644 (file)
@@ -1,3 +1,100 @@
+2008-06-06  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        Combine per-thread objects into one, to make it easier to support legacy clients (for
+        which they shouldn't be really per-thread).
+
+        No change on SunSpider total.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj: Added JSGlobalData.{h,cpp}
+
+        * kjs/JSGlobalData.cpp: Added.
+        (KJS::JSGlobalData::JSGlobalData):
+        (KJS::JSGlobalData::~JSGlobalData):
+        (KJS::JSGlobalData::threadInstance):
+        * kjs/JSGlobalData.h: Added.
+        This class encapsulates all data that should be per-thread (or shared between legacy clients).
+        It will also keep a Heap pointer, but right now, Heap (Collector) methods are all static.
+
+        * kjs/identifier.h:
+        (KJS::Identifier::Identifier):
+        Added a constructor explicitly taking JSGlobalData to access IdentifierTable. Actually,
+        all of them should, but this will be a separate patch.
+
+        * kjs/identifier.cpp:
+        (KJS::IdentifierTable::literalTable):
+        (KJS::createIdentifierTable):
+        (KJS::deleteIdentifierTable):
+        (KJS::Identifier::add):
+        (KJS::Identifier::addSlowCase):
+        Combined IdentifierTable and LiteralIdentifierTable into a single class for simplicity.
+
+        * kjs/grammar.y: kjsyyparse now takes JSGlobalData, not just a Lexer.
+
+        * kjs/nodes.cpp:
+        (KJS::Node::Node):
+        (KJS::EvalFunctionCallNode::emitCode):
+        (KJS::ScopeNode::ScopeNode):
+        Changed to access Lexer and Parser via JSGlobalData::threadInstance(). This is also a
+        temporary measure, they will need to use JSGlobalData explicitly.
+
+        * VM/CodeGenerator.cpp:
+        (KJS::CodeGenerator::CodeGenerator):
+        * VM/CodeGenerator.h:
+        * VM/Machine.cpp:
+        (KJS::callEval):
+        * kjs/CommonIdentifiers.cpp:
+        (KJS::CommonIdentifiers::CommonIdentifiers):
+        * kjs/CommonIdentifiers.h:
+        * kjs/DebuggerCallFrame.cpp:
+        (KJS::DebuggerCallFrame::evaluate):
+        * kjs/ExecState.cpp:
+        (KJS::ExecState::ExecState):
+        * kjs/ExecState.h:
+        (KJS::ExecState::globalData):
+        (KJS::ExecState::identifierTable):
+        (KJS::ExecState::propertyNames):
+        (KJS::ExecState::emptyList):
+        (KJS::ExecState::lexer):
+        (KJS::ExecState::parser):
+        (KJS::ExecState::arrayTable):
+        (KJS::ExecState::dateTable):
+        (KJS::ExecState::mathTable):
+        (KJS::ExecState::numberTable):
+        (KJS::ExecState::RegExpImpTable):
+        (KJS::ExecState::RegExpObjectImpTable):
+        (KJS::ExecState::stringTable):
+        * kjs/InitializeThreading.cpp:
+        (KJS::initializeThreadingOnce):
+        * kjs/JSGlobalObject.cpp:
+        (KJS::JSGlobalObject::init):
+        * kjs/JSGlobalObject.h:
+        (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
+        (KJS::JSGlobalObject::head):
+        (KJS::JSGlobalObject::globalData):
+        * kjs/Parser.cpp:
+        (KJS::Parser::parse):
+        * kjs/Parser.h:
+        * kjs/function.cpp:
+        (KJS::FunctionImp::getParameterName):
+        (KJS::IndexToNameMap::unMap):
+        (KJS::globalFuncEval):
+        * kjs/function_object.cpp:
+        (KJS::FunctionObjectImp::construct):
+        * kjs/interpreter.cpp:
+        (KJS::Interpreter::checkSyntax):
+        (KJS::Interpreter::evaluate):
+        * kjs/lexer.cpp:
+        (kjsyylex):
+        * kjs/lexer.h:
+        * kjs/testkjs.cpp:
+        (prettyPrintScript):
+        Updated for the above changes. Most of threadInstance uses here will need to be replaced with
+        explicitly passed pointers to support legacy JSC clients.
+
+        * JavaScriptCore.exp: Removed KJS::parser().
+
 2008-06-06  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
 
         Reviewed by Oliver.
index 4ba228f77341c7d0b6167ff33df331fe46ae66a7..b1e006e7ea8dae740c55bddde890366e980566ff 100644 (file)
@@ -82,7 +82,6 @@ __ZN3KJS6JSLock4lockEv
 __ZN3KJS6JSLock6unlockEv
 __ZN3KJS6JSLock9lockCountEv
 __ZN3KJS6Parser5parseEPNS_9ExecStateERKNS_7UStringEiN3WTF10PassRefPtrINS_14SourceProviderEEEPiSA_PS3_
-__ZN3KJS6parserEv
 __ZN3KJS6strtodEPKcPPc
 __ZN3KJS7CStringaSERKS0_
 __ZN3KJS7CStringD1Ev
index 2406aacd5149248a523a860e951332af9888ce04..ddc2c9be9f2b85da298acdb49a8795865aaad3bb 100644 (file)
                E11D51760B2E798D0056C188 /* StringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = E11D51750B2E798D0056C188 /* StringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E17863400D9BEC0000D74E75 /* InitializeThreading.h in Headers */ = {isa = PBXBuildFile; fileRef = E178633F0D9BEC0000D74E75 /* InitializeThreading.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E178636D0D9BEEC300D74E75 /* InitializeThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */; };
+               E18E3A580DF9278C00D90B34 /* JSGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E3A560DF9278C00D90B34 /* JSGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E18E3A590DF9278C00D90B34 /* JSGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18E3A570DF9278C00D90B34 /* JSGlobalData.cpp */; };
                E195679609E7CF1200B89D13 /* UnicodeIcu.h in Headers */ = {isa = PBXBuildFile; fileRef = E195678F09E7CF1200B89D13 /* UnicodeIcu.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E195679809E7CF1200B89D13 /* Unicode.h in Headers */ = {isa = PBXBuildFile; fileRef = E195679409E7CF1200B89D13 /* Unicode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1A596380DE3E1C300C17E37 /* AVLTree.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A596370DE3E1C300C17E37 /* AVLTree.h */; };
                E11D51750B2E798D0056C188 /* StringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringExtras.h; sourceTree = "<group>"; };
                E178633F0D9BEC0000D74E75 /* InitializeThreading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitializeThreading.h; sourceTree = "<group>"; };
                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeThreading.cpp; sourceTree = "<group>"; };
+               E18E3A560DF9278C00D90B34 /* JSGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalData.h; sourceTree = "<group>"; };
+               E18E3A570DF9278C00D90B34 /* JSGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalData.cpp; sourceTree = "<group>"; };
                E195678F09E7CF1200B89D13 /* UnicodeIcu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnicodeIcu.h; sourceTree = "<group>"; };
                E195679409E7CF1200B89D13 /* Unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unicode.h; sourceTree = "<group>"; };
                E1A596370DE3E1C300C17E37 /* AVLTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVLTree.h; sourceTree = "<group>"; };
                                F692A8640255597D01FF60F7 /* interpreter.h */,
                                14DA818F0D99FD2000B0A4FB /* JSActivation.cpp */,
                                14DA818E0D99FD2000B0A4FB /* JSActivation.h */,
+                               E18E3A560DF9278C00D90B34 /* JSGlobalData.h */,
+                               E18E3A570DF9278C00D90B34 /* JSGlobalData.cpp */,
                                14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */,
                                A8E894330CD0603F00367179 /* JSGlobalObject.h */,
                                14760863099C633800437128 /* JSImmediate.cpp */,
                                A72701B50DADE94900E548D7 /* ExceptionHelpers.h in Headers */,
                                A7C31DA90DBEBA4300FDF8EB /* SegmentedVector.h in Headers */,
                                1480DB9D0DDC227F003CFDF2 /* DebuggerCallFrame.h in Headers */,
+                               E18E3A580DF9278C00D90B34 /* JSGlobalData.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                14D797810DAC3307001A9F05 /* RegisterFileStack.cpp in Sources */,
                                A72701B60DADE94900E548D7 /* ExceptionHelpers.cpp in Sources */,
                                149559EE0DDCDDF700648087 /* DebuggerCallFrame.cpp in Sources */,
+                               E18E3A590DF9278C00D90B34 /* JSGlobalData.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 4388ad114231f009bcd0b3acece02589369356b6..cdb6cc6ad74909ed4399d9bb386bc17e9deed01a 100644 (file)
@@ -179,7 +179,7 @@ CodeGenerator::CodeGenerator(ProgramNode* programNode, const Debugger* debugger,
     , m_codeType(GlobalCode)
     , m_continueDepth(0)
     , m_nextVar(-1)
-    , m_propertyNames(CommonIdentifiers::shared())
+    , m_propertyNames(&scopeChain.globalObject()->globalExec()->propertyNames())
 {
     // Global code can inherit previously defined symbols.
     int size = symbolTable->size() + 1; // + 1 slot for  "this"
@@ -237,7 +237,7 @@ CodeGenerator::CodeGenerator(FunctionBodyNode* functionBody, const Debugger* deb
     , m_codeType(FunctionCode)
     , m_continueDepth(0)
     , m_nextVar(-1)
-    , m_propertyNames(CommonIdentifiers::shared())
+    , m_propertyNames(&scopeChain.globalObject()->globalExec()->propertyNames())
 {
     const Node::FunctionStack& functionStack = functionBody->functionStack();
     for (size_t i = 0; i < functionStack.size(); ++i) {
@@ -284,7 +284,7 @@ CodeGenerator::CodeGenerator(EvalNode* evalNode, const Debugger* debugger, const
     , m_codeType(EvalCode)
     , m_continueDepth(0)
     , m_nextVar(-1)
-    , m_propertyNames(CommonIdentifiers::shared())
+    , m_propertyNames(&scopeChain.globalObject()->globalExec()->propertyNames())
 {
     m_codeBlock->numVars = 1; // Allocate space for "this"
 }
index bec053ed4e56f7ad1ebf6e2fd924136fbbd419d7..e4edbe0453fad5617d6319368a74cdf02a66a275 100644 (file)
@@ -371,7 +371,7 @@ namespace KJS {
         IdentifierMap m_identifierMap;
         JSValueMap m_jsValueMap;
 
-        CommonIdentifiers* m_propertyNames;
+        const CommonIdentifiers* m_propertyNames;
 
 #ifndef NDEBUG
         static bool s_dumpsGeneratedCode;
index a1f4454b60d15a0af3ab6998824dd80a6d014011..7220727fc2d315f5da8beb5e40b0e8735281fe71 100644 (file)
@@ -446,7 +446,7 @@ static NEVER_INLINE JSValue* callEval(ExecState* exec, JSObject* thisObj, ScopeC
     int sourceId;
     int errLine;
     UString errMsg;
-    RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(static_cast<StringImp*>(program)->value()), &sourceId, &errLine, &errMsg);
+    RefPtr<EvalNode> evalNode = exec->parser()->parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(static_cast<StringImp*>(program)->value()), &sourceId, &errLine, &errMsg);
 
     if (!evalNode) {
         exceptionValue = Error::create(exec, SyntaxError, errMsg, errLine, sourceId, NULL);
index 00181fe2a12a4a038a5fb8ee6ab4b68b14ed7c66..764c0ee9f57e5a405a50292ba2fdc4808a96d25d 100644 (file)
 #include "config.h"
 #include "CommonIdentifiers.h"
 
-#if USE(MULTIPLE_THREADS)
-#include <wtf/ThreadSpecific.h>
-using namespace WTF;
-#endif
-
 namespace KJS {
 
 const char* const nullCString = 0;
 
-#define INITIALIZE_PROPERTY_NAME(name) , name ( #name )
+#define INITIALIZE_PROPERTY_NAME(name) , name(globalData, #name)
 
-CommonIdentifiers::CommonIdentifiers()
-    : nullIdentifier(nullCString)
-    , underscoreProto("__proto__")
-    , thisIdentifier("this")
+CommonIdentifiers::CommonIdentifiers(JSGlobalData* globalData)
+    : nullIdentifier(globalData, nullCString)
+    , underscoreProto(globalData, "__proto__")
+    , thisIdentifier(globalData, "this")
     KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME)
 {
 }
 
-CommonIdentifiers* CommonIdentifiers::shared()
-{
-#if USE(MULTIPLE_THREADS)
-    static ThreadSpecific<CommonIdentifiers> sharedInstance;
-    return sharedInstance;
-#else
-    static CommonIdentifiers sharedInstance;
-    return &sharedInstance;
-#endif
-}
-
 } // namespace KJS
index d7507b557ab3ea02af565b6a64d1450cb2a4ad51..e6e91128b3b89d3972a90e951e0e7826eeaa9388 100644 (file)
 #include "identifier.h"
 #include <wtf/Noncopyable.h>
 
-namespace WTF {
-    template<typename T> class ThreadSpecific;
-}
-
 // 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) \
@@ -74,12 +70,10 @@ namespace KJS {
     class CommonIdentifiers : Noncopyable {
 
     private:
-        CommonIdentifiers();
-        friend class WTF::ThreadSpecific<CommonIdentifiers>;
+        CommonIdentifiers(JSGlobalData*);
+        friend struct JSGlobalData;
 
     public:
-        static CommonIdentifiers* shared();
-
         const Identifier nullIdentifier;
         const Identifier underscoreProto;
         const Identifier thisIdentifier;
index ff1c2d3eee35d9adbcedb93c6ee5eb9ac80960d7..952e3525f9eae96a96cb0b0774bb081691e27f14 100644 (file)
@@ -73,7 +73,7 @@ JSValue* DebuggerCallFrame::evaluate(const UString& script, JSValue*& exception)
     int errLine;
     UString errMsg;
 
-    RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(&newExec, UString(), 1, UStringSourceProvider::create(script), &sourceId, &errLine, &errMsg);
+    RefPtr<EvalNode> evalNode = newExec.parser()->parse<EvalNode>(&newExec, UString(), 1, UStringSourceProvider::create(script), &sourceId, &errLine, &errMsg);
 
     if (!evalNode)
         return Error::create(&newExec, SyntaxError, errMsg, errLine, sourceId, 0);
index db89422e75fe536ddda2281ea654a218012122b6..907cc279e12691818d52daff0ad7dfd31f22982f 100644 (file)
@@ -35,7 +35,7 @@ ExecState::ExecState(JSGlobalObject* globalObject, JSObject* globalThisValue, Sc
     : m_globalObject(globalObject)
     , m_globalThisValue(globalThisValue)
     , m_exception(0)
-    , m_perThreadData(globalObject->perThreadData())
+    , m_globalData(globalObject->globalData())
     , m_prev(0)
     , m_machine(0)
     , m_registerFile(0)
@@ -48,7 +48,7 @@ ExecState::ExecState(ExecState* exec, Machine* machine, RegisterFile* registerFi
     : m_globalObject(exec->m_globalObject)
     , m_globalThisValue(exec->m_globalThisValue)
     , m_exception(0)
-    , m_perThreadData(exec->m_globalObject->perThreadData())
+    , m_globalData(exec->m_globalData)
     , m_prev(exec)
     , m_machine(machine)
     , m_registerFile(registerFile)
index defd433fbbd5d26d2c7df095fcb384079c6a44d0..e40fe73b20341a70c7c1550fc376244f27f996c0 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef ExecState_h
 #define ExecState_h
 
+#include "JSGlobalData.h"
 #include "LabelStack.h"
 #include "LocalStorageEntry.h"
 #include "completion.h"
 
 namespace KJS  {
 
-    class CommonIdentifiers;
     class EvalNode;
     class FunctionBodyNode;
     class FunctionImp;
     class GlobalFuncImp;
-    struct HashTable;
     class Interpreter;
     class JSGlobalObject;
     class JSVariableObject;
@@ -48,19 +47,6 @@ namespace KJS  {
 
     struct Instruction;
     
-    struct PerThreadData {
-        const HashTable* arrayTable;
-        const HashTable* dateTable;
-        const HashTable* mathTable;
-        const HashTable* numberTable;
-        const HashTable* RegExpImpTable;
-        const HashTable* RegExpObjectImpTable;
-        const HashTable* stringTable;
-
-        CommonIdentifiers* propertyNames;
-        List emptyList;
-    };
-
     // Represents the current state of script execution.
     // Passed as the first argument to most functions.
     class ExecState : Noncopyable {
@@ -91,17 +77,20 @@ namespace KJS  {
         JSValue** exceptionSlot() { return &m_exception; }
         bool hadException() const { return !!m_exception; }
 
-        // These pointers are used to avoid accessing global variables for these,
-        // to avoid taking PIC branches in Mach-O binaries.
-        const CommonIdentifiers& propertyNames() const { return *m_perThreadData->propertyNames; }
-        const List& emptyList() const { return m_perThreadData->emptyList; }
-        static const HashTable* arrayTable(ExecState* exec) { return exec->m_perThreadData->arrayTable; }
-        static const HashTable* dateTable(ExecState* exec) { return exec->m_perThreadData->dateTable; }
-        static const HashTable* mathTable(ExecState* exec) { return exec->m_perThreadData->mathTable; }
-        static const HashTable* numberTable(ExecState* exec) { return exec->m_perThreadData->numberTable; }
-        static const HashTable* RegExpImpTable(ExecState* exec) { return exec->m_perThreadData->RegExpImpTable; }
-        static const HashTable* RegExpObjectImpTable(ExecState* exec) { return exec->m_perThreadData->RegExpObjectImpTable; }
-        static const HashTable* stringTable(ExecState* exec) { return exec->m_perThreadData->stringTable; }
+        JSGlobalData& globalData() { return *m_globalData; }
+
+        IdentifierTable* identifierTable() { return m_globalData->identifierTable; }
+        const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
+        const List& emptyList() const { return m_globalData->emptyList; }
+        Lexer* lexer() { return m_globalData->lexer; }
+        Parser* parser() { return m_globalData->parser; }
+        static const HashTable* arrayTable(ExecState* exec) { return exec->m_globalData->arrayTable; }
+        static const HashTable* dateTable(ExecState* exec) { return exec->m_globalData->dateTable; }
+        static const HashTable* mathTable(ExecState* exec) { return exec->m_globalData->mathTable; }
+        static const HashTable* numberTable(ExecState* exec) { return exec->m_globalData->numberTable; }
+        static const HashTable* RegExpImpTable(ExecState* exec) { return exec->m_globalData->RegExpImpTable; }
+        static const HashTable* RegExpObjectImpTable(ExecState* exec) { return exec->m_globalData->RegExpObjectImpTable; }
+        static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
 
     private:
         // Default constructor required for gcc 3.
@@ -116,7 +105,7 @@ namespace KJS  {
 
         JSValue* m_exception;
 
-        const PerThreadData* m_perThreadData;
+        JSGlobalData* m_globalData;
 
         // These values are controlled by the machine.
         ExecState* m_prev;
index f69a21aab34954b79230522e7247827b249b586b..40b5423fca80c8bc971925b01d2ecce20b8584d1 100644 (file)
@@ -34,8 +34,6 @@
 #include "dtoa.h"
 #include "identifier.h"
 #include "JSGlobalObject.h"
-#include "lexer.h"
-#include "Parser.h"
 #include "ustring.h"
 #include <wtf/Threading.h>
 
@@ -53,13 +51,9 @@ static void initializeThreadingOnce()
 #if !PLATFORM(DARWIN) // Darwin has pthread_main_np(), and doesn't need registerAsMainThread() called.
     Collector::registerAsMainThread();
 #endif
+    JSGlobalData::threadInstance();
     UString::null();
-    Identifier::initializeIdentifierThreading();
-    CommonIdentifiers::shared();
-    lexer();
     initDateMath();
-    JSGlobalObject::threadClassInfoHashTables();
-    JSGlobalObject::head();
 #endif
 }
 
diff --git a/JavaScriptCore/kjs/JSGlobalData.cpp b/JavaScriptCore/kjs/JSGlobalData.cpp
new file mode 100644 (file)
index 0000000..bb46ab3
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSGlobalData.h"
+
+#include "collector.h"
+#include "CommonIdentifiers.h"
+#include "lexer.h"
+#include "list.h"
+#include "lookup.h"
+#include "nodes.h"
+#include "parser.h"
+
+#if USE(MULTIPLE_THREADS)
+#include <wtf/ThreadSpecific.h>
+#endif
+
+using namespace WTF;
+
+namespace KJS {
+
+extern const HashTable arrayTable;
+extern const HashTable dateTable;
+extern const HashTable mathTable;
+extern const HashTable numberTable;
+extern const HashTable RegExpImpTable;
+extern const HashTable RegExpObjectImpTable;
+extern const HashTable stringTable;
+
+
+JSGlobalData::JSGlobalData()
+//    : heap(new Heap)
+#if USE(MULTIPLE_THREADS)
+    : arrayTable(new HashTable(KJS::arrayTable))
+    , dateTable(new HashTable(KJS::dateTable))
+    , mathTable(new HashTable(KJS::mathTable))
+    , numberTable(new HashTable(KJS::numberTable))
+    , RegExpImpTable(new HashTable(KJS::RegExpImpTable))
+    , RegExpObjectImpTable(new HashTable(KJS::RegExpObjectImpTable))
+    , stringTable(new HashTable(KJS::stringTable))
+#else
+    : arrayTable(&KJS::arrayTable)
+    , dateTable(&KJS::dateTable)
+    , mathTable(&KJS::mathTable)
+    , numberTable(&KJS::numberTable)
+    , RegExpImpTable(&KJS::RegExpImpTable)
+    , RegExpObjectImpTable(&KJS::RegExpObjectImpTable)
+    , stringTable(&KJS::stringTable)
+#endif
+    , identifierTable(createIdentifierTable())
+    , propertyNames(new CommonIdentifiers(this))
+    , lexer(new Lexer)
+    , parser(new Parser)
+    , head(0)
+{
+}
+
+JSGlobalData::~JSGlobalData()
+{
+#if USE(MULTIPLE_THREADS)
+    delete[] arrayTable->table;
+    delete[] dateTable->table;
+    delete[] mathTable->table;
+    delete[] numberTable->table;
+    delete[] RegExpImpTable->table;
+    delete[] RegExpObjectImpTable->table;
+    delete[] stringTable->table;
+    delete arrayTable;
+    delete dateTable;
+    delete mathTable;
+    delete numberTable;
+    delete RegExpImpTable;
+    delete RegExpObjectImpTable;
+    delete stringTable;
+
+    delete parser;
+    delete lexer;
+
+    delete propertyNames;
+    deleteIdentifierTable(identifierTable);
+#endif
+}
+
+JSGlobalData& JSGlobalData::threadInstance()
+{
+#if USE(MULTIPLE_THREADS)
+    static ThreadSpecific<JSGlobalData> sharedInstance;
+    return *sharedInstance;
+#else
+    return globalSharedInstance();
+#endif
+}
+
+}
diff --git a/JavaScriptCore/kjs/JSGlobalData.h b/JavaScriptCore/kjs/JSGlobalData.h
new file mode 100644 (file)
index 0000000..38a039e
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSGlobalData_h
+#define JSGlobalData_h
+
+#include "list.h"
+#include <wtf/HashCountedSet.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+
+namespace WTF {
+    template<typename> class ThreadSpecific;
+}
+
+namespace KJS {
+
+    class CommonIdentifiers;
+//    class Heap;
+    class IdentifierTable;
+    class JSGlobalObject;
+    class Lexer;
+    class Parser;
+    class ParserRefCounted;
+    class UString;
+    struct HashTable;
+    struct UString::Rep;
+
+    // This serves as a bottleneck for accessing per-thread data structures.
+    // Note that the effective instance may be different from the thread one in case of legacy
+    // JavaScriptCore clients, which all share a single JSGlobalData, and thus cannot run concurrently.
+    struct JSGlobalData : Noncopyable {
+        static JSGlobalData& threadInstance();
+
+//        Heap* heap;
+
+        const HashTable* arrayTable;
+        const HashTable* dateTable;
+        const HashTable* mathTable;
+        const HashTable* numberTable;
+        const HashTable* RegExpImpTable;
+        const HashTable* RegExpObjectImpTable;
+        const HashTable* stringTable;
+
+        IdentifierTable* identifierTable;
+        CommonIdentifiers* propertyNames;
+        const List emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.
+
+        HashSet<ParserRefCounted*> newTrackedObjects;
+        HashCountedSet<ParserRefCounted*> trackedObjectExtraRefCounts;
+
+        Lexer* lexer;
+        Parser* parser;
+
+        JSGlobalObject* head;
+
+    private:
+        friend class WTF::ThreadSpecific<JSGlobalData>;
+
+        JSGlobalData();
+        ~JSGlobalData();
+    };
+
+}
+
+#endif
index c57503f083c8d92d29b7337bc01df37492274bee..d1f0c8061b9fe75bd6a843fbb40846807c909809 100644 (file)
 #include "scope_chain_mark.h"
 #include "string_object.h"
 
-#if USE(MULTIPLE_THREADS)
-#include <wtf/ThreadSpecific.h>
-using namespace WTF;
-#endif
-
 #if HAVE(SYS_TIME_H)
 #include <sys/time.h>
 #endif
@@ -63,14 +58,6 @@ using namespace WTF;
 
 namespace KJS {
 
-extern const HashTable arrayTable;
-extern const HashTable dateTable;
-extern const HashTable mathTable;
-extern const HashTable numberTable;
-extern const HashTable RegExpImpTable;
-extern const HashTable RegExpObjectImpTable;
-extern const HashTable stringTable;
-
 // Default number of ticks before a timeout check should be done.
 static const int initialTickCountThreshold = 255;
 
@@ -124,61 +111,6 @@ JSGlobalObject::~JSGlobalObject()
     delete d();
 }
 
-struct ThreadClassInfoHashTables {
-    ThreadClassInfoHashTables()
-        : arrayTable(KJS::arrayTable)
-        , dateTable(KJS::dateTable)
-        , mathTable(KJS::mathTable)
-        , numberTable(KJS::numberTable)
-        , RegExpImpTable(KJS::RegExpImpTable)
-        , RegExpObjectImpTable(KJS::RegExpObjectImpTable)
-        , stringTable(KJS::stringTable)
-    {
-    }
-
-    ~ThreadClassInfoHashTables()
-    {
-#if USE(MULTIPLE_THREADS)
-        delete[] arrayTable.table;
-        delete[] dateTable.table;
-        delete[] mathTable.table;
-        delete[] numberTable.table;
-        delete[] RegExpImpTable.table;
-        delete[] RegExpObjectImpTable.table;
-        delete[] stringTable.table;
-#endif
-    }
-
-#if USE(MULTIPLE_THREADS)
-    HashTable arrayTable;
-    HashTable dateTable;
-    HashTable mathTable;
-    HashTable numberTable;
-    HashTable RegExpImpTable;
-    HashTable RegExpObjectImpTable;
-    HashTable stringTable;
-#else
-    const HashTable& arrayTable;
-    const HashTable& dateTable;
-    const HashTable& mathTable;
-    const HashTable& numberTable;
-    const HashTable& RegExpImpTable;
-    const HashTable& RegExpObjectImpTable;
-    const HashTable& stringTable;
-#endif
-};
-
-ThreadClassInfoHashTables* JSGlobalObject::threadClassInfoHashTables()
-{
-#if USE(MULTIPLE_THREADS)
-    static ThreadSpecific<ThreadClassInfoHashTables> sharedInstance;
-    return sharedInstance;
-#else
-    static ThreadClassInfoHashTables sharedInstance;
-    return &sharedInstance;
-#endif
-}
-
 void JSGlobalObject::init(JSObject* thisValue)
 {
     ASSERT(JSLock::currentThreadIsHoldingLock());
@@ -198,14 +130,7 @@ void JSGlobalObject::init(JSObject* thisValue)
     d()->recursion = 0;
     d()->debugger = 0;
     
-    d()->perThreadData.arrayTable = &threadClassInfoHashTables()->arrayTable;
-    d()->perThreadData.dateTable = &threadClassInfoHashTables()->dateTable;
-    d()->perThreadData.mathTable = &threadClassInfoHashTables()->mathTable;
-    d()->perThreadData.numberTable = &threadClassInfoHashTables()->numberTable;
-    d()->perThreadData.RegExpImpTable = &threadClassInfoHashTables()->RegExpImpTable;
-    d()->perThreadData.RegExpObjectImpTable = &threadClassInfoHashTables()->RegExpObjectImpTable;
-    d()->perThreadData.stringTable = &threadClassInfoHashTables()->stringTable;
-    d()->perThreadData.propertyNames = CommonIdentifiers::shared();
+    d()->globalData = &JSGlobalData::threadInstance();
 
     d()->globalExec.set(new ExecState(this, thisValue, d()->globalScopeChain.node()));
 
index bd96c8fa4f04048183a6f2bdac49cd80e12a94c5..5df3ae58a323c55c575a5f078db5f45500286b88 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef KJS_GlobalObject_h
 #define KJS_GlobalObject_h
 
+#include "JSGlobalData.h"
 #include "JSVariableObject.h"
 #include "RegisterFile.h"
 #include "RegisterFileStack.h"
@@ -71,7 +72,6 @@ namespace KJS {
     class UriError;
     class UriErrorPrototype;
     struct ActivationStackNode;
-    struct ThreadClassInfoHashTables;
 
     typedef Vector<ExecState*, 16> ExecStateStack;
 
@@ -83,7 +83,6 @@ namespace KJS {
             JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
                 : JSVariableObjectData(&symbolTable, registerFileStack.globalBasePointer(), 0)
                 , globalScopeChain(globalObject, thisValue)
-                , globalExec(new ExecState(globalObject, thisValue, globalScopeChain.node()))
             {
             }
 
@@ -142,7 +141,7 @@ namespace KJS {
             SymbolTable symbolTable;
             unsigned pageGroupIdentifier;
 
-            PerThreadData perThreadData;
+            JSGlobalData* globalData;
 
             HashSet<ProgramCodeBlock*> codeBlocks;
 
@@ -175,8 +174,8 @@ namespace KJS {
         virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunc);
         virtual void defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunc);
 
-        // Linked list of all global objects.
-        static JSGlobalObject* head() { return s_head; }
+        // Per-thread linked list of all global objects.
+        static JSGlobalObject*& head() { return JSGlobalData::threadInstance().head; }
         JSGlobalObject* next() { return d()->next; }
 
         // Resets the global object to contain only built-in properties, sets
@@ -259,10 +258,7 @@ namespace KJS {
         RegisterFileStack& registerFileStack() { return d()->registerFileStack; }
 
         // Per-thread hash tables, cached on the global object for faster access.
-        const PerThreadData* perThreadData() const { return &d()->perThreadData; }
-
-        // Initialize and/or retrieve per-thread hash tables - use perThreadData() for faster access instead.
-        static ThreadClassInfoHashTables* threadClassInfoHashTables();
+        JSGlobalData* globalData() { return d()->globalData; }
 
         void init(JSObject* thisValue);
         
index 5328f6a776710251076c6e4b29b7c582564d6994..90054ec45ecac0d3a02fef662ea0629bc7a5d4f7 100644 (file)
 
 #include "lexer.h"
 #include <wtf/HashSet.h>
-#if USE(MULTIPLE_THREADS)
-#include <wtf/ThreadSpecific.h>
-using namespace WTF;
-#endif
 #include <wtf/Vector.h>
 
 extern int kjsyyparse(void*);
@@ -65,7 +61,7 @@ void Parser::parse(ExecState* exec, const UString& sourceURL, int startingLineNu
     *errLine = -1;
     *errMsg = 0;
         
-    Lexer& lexer = KJS::lexer();
+    Lexer& lexer = *JSGlobalData::threadInstance().lexer;
 
     ASSERT(startingLineNumber > 0);
     if (startingLineNumber <= 0)
@@ -74,7 +70,7 @@ void Parser::parse(ExecState* exec, const UString& sourceURL, int startingLineNu
     lexer.setCode(startingLineNumber, source);
     *sourceId = ++m_sourceId;
 
-    int parseError = kjsyyparse(&lexer);
+    int parseError = kjsyyparse(&JSGlobalData::threadInstance());
     bool lexError = lexer.sawError();
     lexer.clear();
 
@@ -101,15 +97,4 @@ void Parser::didFinishParsing(SourceElements* sourceElements, ParserRefCountedDa
     m_lastLine = lastLine;
 }
 
-Parser& parser()
-{
-#if USE(MULTIPLE_THREADS)
-    static ThreadSpecific<Parser> staticParser;
-    return *staticParser;
-#else
-    static Parser staticParser;
-    return staticParser;
-#endif
-}
-
 } // namespace KJS
index cbfad36d5c886e9e5e245288f468eab47c2d700b..a305f7362bd084fd9466c8c34cecd87974b0b67b 100644 (file)
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
 
-namespace WTF {
-    template<typename T> class ThreadSpecific;
-}
-
 namespace KJS {
 
     class FunctionBodyNode;
@@ -60,10 +56,9 @@ namespace KJS {
                               ParserRefCountedData<DeclarationStacks::FunctionStack>*, bool usesEval, bool needsClosure, int lastLine);
 
     private:
-        friend Parser& parser();
-        friend class WTF::ThreadSpecific<Parser>;
+        friend struct JSGlobalData;
+        Parser();
 
-        Parser(); // Use parser() instead.
         void parse(ExecState*, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source,
                    int* sourceId, int* errLine, UString* errMsg);
 
@@ -76,8 +71,6 @@ namespace KJS {
         bool m_needsClosure;
         int m_lastLine;
     };
-    
-    Parser& parser(); // Returns the singleton JavaScript parser.
 
     template <class ParsedNode>
     PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, const UString& sourceURL, int startingLineNumber,
index 940621e15933f1fc39a0f0e5809b05f99fadbe3b..d28af105563b3b1a727348ef505dc2e268819e84 100644 (file)
@@ -165,7 +165,7 @@ Identifier FunctionImp::getParameterName(int index)
     Vector<Identifier>& parameters = body->parameters();
 
     if (static_cast<size_t>(index) >= body->parameters().size())
-        return CommonIdentifiers::shared()->nullIdentifier;
+        return JSGlobalData::threadInstance().propertyNames->nullIdentifier;
   
     Identifier name = parameters[index];
 
@@ -173,7 +173,7 @@ Identifier FunctionImp::getParameterName(int index)
     size_t size = parameters.size();
     for (size_t i = index + 1; i < size; ++i)
         if (parameters[i] == name)
-            return CommonIdentifiers::shared()->nullIdentifier;
+            return JSGlobalData::threadInstance().propertyNames->nullIdentifier;
 
     return name;
 }
@@ -260,7 +260,7 @@ void IndexToNameMap::unMap(const Identifier& index)
 
   ASSERT(indexIsNumber && indexAsNumber < size);
   
-  _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier;
+  _map[indexAsNumber] = JSGlobalData::threadInstance().propertyNames->nullIdentifier;
 }
 
 Identifier& IndexToNameMap::operator[](const Identifier& index)
@@ -574,7 +574,7 @@ JSValue* globalFuncEval(ExecState* exec, PrototypeReflexiveFunction* function, J
     int errLine;
     UString errMsg;
 
-    RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(s), &sourceId, &errLine, &errMsg);
+    RefPtr<EvalNode> evalNode = exec->parser()->parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(s), &sourceId, &errLine, &errMsg);
     
     if (!evalNode)
         return throwError(exec, SyntaxError, errMsg, errLine, sourceId, NULL);
index 9e0b88ed30db3c70cb827fdb52008b76a9d8b792..91c3ce5b3078e36a7806604ebfa0b45e0c09ce90 100644 (file)
@@ -163,7 +163,7 @@ JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args, const
     int errLine;
     UString errMsg;
     RefPtr<SourceProvider> source = UStringSourceProvider::create(body);
-    RefPtr<FunctionBodyNode> functionBody = parser().parse<FunctionBodyNode>(exec, sourceURL, lineNumber, source, &sourceId, &errLine, &errMsg);
+    RefPtr<FunctionBodyNode> functionBody = exec->parser()->parse<FunctionBodyNode>(exec, sourceURL, lineNumber, source, &sourceId, &errLine, &errMsg);
 
     // No program node == syntax error - throw a syntax error
     if (!functionBody)
index d7d449d8a3747651b177b025e6be486d0e27e1f1..473b05a1f5d5a363e18e619f9b5bfd0bd28dab13 100644 (file)
@@ -33,6 +33,7 @@
 #include "nodes.h"
 #include "lexer.h"
 #include "internal.h"
+#include "JSGlobalData.h"
 #include "CommonIdentifiers.h"
 #include "NodeInfo.h"
 #include "Parser.h"
 #define YYERROR_VERBOSE
 #endif
 
-#define LEXER (static_cast<KJS::Lexer*>(lexer))
-
-int kjsyylex(void* lvalp, void* llocp, void* lexer);
+int kjsyylex(void* lvalp, void* llocp, void* globalPtr);
 int kjsyyerror(const char*);
 static inline bool allowAutomaticSemicolon(KJS::Lexer&, int);
 
+#define GLOBAL_DATA static_cast<JSGlobalData*>(globalPtr)
+#define LEXER (GLOBAL_DATA->lexer)
+
 #define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0)
 #define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line)
 
@@ -66,8 +68,8 @@ static LessNode* makeLessNode(ExpressionNode*, ExpressionNode*);
 static ExpressionNode* makeAssignNode(ExpressionNode* loc, Operator, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments);
 static ExpressionNode* makePrefixNode(ExpressionNode* expr, Operator);
 static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator);
-static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceRange&);
-static ExpressionNodeInfo makeFunctionCallNode(ExpressionNodeInfo func, ArgumentsNodeInfo);
+static PropertyNode* makeGetterOrSetterPropertyNode(void*, const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceRange&);
+static ExpressionNodeInfo makeFunctionCallNode(void*, ExpressionNodeInfo func, ArgumentsNodeInfo);
 static ExpressionNode* makeTypeOfNode(ExpressionNode*);
 static ExpressionNode* makeDeleteNode(ExpressionNode*);
 static ExpressionNode* makeNegateNode(ExpressionNode*);
@@ -90,8 +92,8 @@ static ExpressionNode* combineVarInitializers(ExpressionNode* list, AssignResolv
 
 #endif
 
-#define YYPARSE_PARAM lexer
-#define YYLEX_PARAM lexer
+#define YYPARSE_PARAM globalPtr
+#define YYLEX_PARAM globalPtr
 
 template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls, 
                                                                        ParserRefCountedData<DeclarationStacks::FunctionStack>* funcDecls,
@@ -302,9 +304,9 @@ Property:
     IDENT ':' AssignmentExpr            { $$ = createNodeFeatureInfo<PropertyNode*>(new PropertyNode(*$1, $3.m_node, PropertyNode::Constant), $3.m_featureInfo); }
   | STRING ':' AssignmentExpr           { $$ = createNodeFeatureInfo<PropertyNode*>(new PropertyNode(Identifier(*$1), $3.m_node, PropertyNode::Constant), $3.m_featureInfo); }
   | NUMBER ':' AssignmentExpr           { $$ = createNodeFeatureInfo<PropertyNode*>(new PropertyNode(Identifier(UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_featureInfo); }
-  | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE    { $$ = createNodeFeatureInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(*$1, *$2, 0, $6, LEXER->sourceRange($5, $7)), ClosureFeature); DBG($6, @5, @7); if (!$$.m_node) YYABORT; }
+  | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE    { $$ = createNodeFeatureInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, 0, $6, LEXER->sourceRange($5, $7)), ClosureFeature); DBG($6, @5, @7); if (!$$.m_node) YYABORT; }
   | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
-                                        { $$ = createNodeFeatureInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(*$1, *$2, $4.head, $7, LEXER->sourceRange($6, $8)), ClosureFeature); DBG($7, @6, @8); if (!$$.m_node) YYABORT; }
+                                        { $$ = createNodeFeatureInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.head, $7, LEXER->sourceRange($6, $8)), ClosureFeature); DBG($7, @6, @8); if (!$$.m_node) YYABORT; }
 ;
 
 PropertyList:
@@ -384,15 +386,15 @@ NewExprNoBF:
 ;
 
 CallExpr:
-    MemberExpr Arguments                { $$ = makeFunctionCallNode($1, $2); }
-  | CallExpr Arguments                  { $$ = makeFunctionCallNode($1, $2); }
+    MemberExpr Arguments                { $$ = makeFunctionCallNode(globalPtr, $1, $2); }
+  | CallExpr Arguments                  { $$ = makeFunctionCallNode(globalPtr, $1, $2); }
   | CallExpr '[' Expr ']'               { $$ = createNodeFeatureInfo<ExpressionNode*>(new BracketAccessorNode($1.m_node, $3.m_node, $3.m_featureInfo & AssignFeature), $1.m_featureInfo | $3.m_featureInfo); }
   | CallExpr '.' IDENT                  { $$ = createNodeFeatureInfo<ExpressionNode*>(new DotAccessorNode($1.m_node, *$3), $1.m_featureInfo); }
 ;
 
 CallExprNoBF:
-    MemberExprNoBF Arguments            { $$ = makeFunctionCallNode($1, $2); }
-  | CallExprNoBF Arguments              { $$ = makeFunctionCallNode($1, $2); }
+    MemberExprNoBF Arguments            { $$ = makeFunctionCallNode(globalPtr, $1, $2); }
+  | CallExprNoBF Arguments              { $$ = makeFunctionCallNode(globalPtr, $1, $2); }
   | CallExprNoBF '[' Expr ']'           { $$ = createNodeFeatureInfo<ExpressionNode*>(new BracketAccessorNode($1.m_node, $3.m_node, $3.m_featureInfo & AssignFeature), $1.m_featureInfo | $3.m_featureInfo); }
   | CallExprNoBF '.' IDENT              { $$ = createNodeFeatureInfo<ExpressionNode*>(new DotAccessorNode($1.m_node, *$3), $1.m_featureInfo); }
 ;
@@ -1001,7 +1003,7 @@ ThrowStatement:
 ;
 
 TryStatement:
-    TRY Block FINALLY Block             { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode($2.m_node, CommonIdentifiers::shared()->nullIdentifier, 0, $4.m_node),
+    TRY Block FINALLY Block             { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode($2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, 0, $4.m_node),
                                                                                          mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations),
                                                                                          mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations),
                                                                                          $2.m_featureInfo | $4.m_featureInfo);
@@ -1033,8 +1035,8 @@ FunctionDeclaration:
 ;
 
 FunctionExpr:
-    FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, LEXER->sourceRange($4, $6)), ClosureFeature); DBG($5, @4, @6); }
-  | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $6, LEXER->sourceRange($5, $7), $3.head), ClosureFeature); DBG($6, @5, @7); }
+    FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(GLOBAL_DATA->propertyNames->nullIdentifier, $5, LEXER->sourceRange($4, $6)), ClosureFeature); DBG($5, @4, @6); }
+  | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(GLOBAL_DATA->propertyNames->nullIdentifier, $6, LEXER->sourceRange($5, $7), $3.head), ClosureFeature); DBG($6, @5, @7); }
   | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(*$2, $6, LEXER->sourceRange($5, $7)), ClosureFeature); DBG($6, @5, @7); }
   | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(*$2, $7, LEXER->sourceRange($6, $8), $4.head), ClosureFeature); DBG($7, @6, @8); }
 ;
@@ -1065,8 +1067,8 @@ FunctionBody:
 ;
 
 Program:
-    /* not in spec */                   { parser().didFinishParsing(new SourceElements, 0, 0, false, false, @0.last_line); }
-    | SourceElements                    { parser().didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, 
+    /* not in spec */                   { GLOBAL_DATA->parser->didFinishParsing(new SourceElements, 0, 0, false, false, @0.last_line); }
+    | SourceElements                    { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, 
                                                                     ($1.m_featureInfo & EvalFeature) != 0, ($1.m_featureInfo & ClosureFeature) != 0,
                                                                     @1.last_line); }
 ;
@@ -1181,7 +1183,7 @@ static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator op)
     return new PostDecDotNode(dot->base(), dot->identifier());
 }
 
-static ExpressionNodeInfo makeFunctionCallNode(ExpressionNodeInfo func, ArgumentsNodeInfo args)
+static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args)
 {
     FeatureInfo features = func.m_featureInfo | args.m_featureInfo;
     if (!func.m_node->isLocation())
@@ -1189,7 +1191,7 @@ static ExpressionNodeInfo makeFunctionCallNode(ExpressionNodeInfo func, Argument
     if (func.m_node->isResolveNode()) {
         ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node);
         const Identifier& identifier = resolve->identifier();
-        if (identifier == CommonIdentifiers::shared()->eval)
+        if (identifier == GLOBAL_DATA->propertyNames->eval)
             return createNodeFeatureInfo<ExpressionNode*>(new EvalFunctionCallNode(args.m_node), EvalFeature | features);
         return createNodeFeatureInfo<ExpressionNode*>(new FunctionCallResolveNode(identifier, args.m_node), features);
     }
@@ -1228,7 +1230,7 @@ static ExpressionNode* makeDeleteNode(ExpressionNode* expr)
     return new DeleteDotNode(dot->base(), dot->identifier());
 }
 
-static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceRange& source)
+static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceRange& source)
 {
     PropertyNode::Type type;
     if (getOrSet == "get")
@@ -1237,7 +1239,7 @@ static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier& getOrSet,
         type = PropertyNode::Setter;
     else
         return 0;
-    return new PropertyNode(name, new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, source, params), type);
+    return new PropertyNode(name, new FuncExprNode(GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type);
 }
 
 static ExpressionNode* makeNegateNode(ExpressionNode* n)
@@ -1291,3 +1293,4 @@ static StatementNode* makeVarStatementNode(ExpressionNode* expr)
     return new VarStatementNode(expr);
 }
 
+#undef GLOBAL_DATA
index c062aa421ae5a0c598cd9ffd39b086e3ed21bfb7..304e4ca0f36e3ccf2b1cab3bfe7a5f26690058fb 100644 (file)
 #include <wtf/Assertions.h>
 #include <wtf/FastMalloc.h>
 #include <wtf/HashSet.h>
-#if USE(MULTIPLE_THREADS)
-#include <wtf/ThreadSpecific.h>
-using namespace WTF;
-#endif
 
 namespace KJS {
 
+typedef HashMap<const char*, RefPtr<UString::Rep>, PtrHash<const char*> > LiteralIdentifierTable;
+
 class IdentifierTable {
 public:
     ~IdentifierTable()
@@ -61,38 +59,21 @@ public:
 
     void remove(UString::Rep* r) { m_table.remove(r); }
 
+    LiteralIdentifierTable& literalTable() { return m_literalTable; }
+
 private:
     HashSet<UString::Rep*> m_table;
+    LiteralIdentifierTable m_literalTable;
 };
 
-typedef HashMap<const char*, RefPtr<UString::Rep>, PtrHash<const char*> > LiteralIdentifierTable;
-
-static inline IdentifierTable& identifierTable()
+IdentifierTable* createIdentifierTable()
 {
-#if USE(MULTIPLE_THREADS)
-    static ThreadSpecific<IdentifierTable> table;
-    return *table;
-#else
-    static IdentifierTable table;
-    return table;
-#endif
+    return new IdentifierTable;
 }
 
-static inline LiteralIdentifierTable& literalIdentifierTable()
+void deleteIdentifierTable(IdentifierTable* table)
 {
-#if USE(MULTIPLE_THREADS)
-    static ThreadSpecific<LiteralIdentifierTable> table;
-    return *table;
-#else
-    static LiteralIdentifierTable table;
-    return table;
-#endif
-}
-
-void Identifier::initializeIdentifierThreading()
-{
-    identifierTable();
-    literalIdentifierTable();
+    delete table;
 }
 
 bool Identifier::equal(const UString::Rep *r, const char *s)
@@ -155,14 +136,40 @@ PassRefPtr<UString::Rep> Identifier::add(const char* c)
         return &UString::Rep::empty;
     }
 
-    LiteralIdentifierTable& literalTableLocalRef = literalIdentifierTable();
+    IdentifierTable& identifierTable = *JSGlobalData::threadInstance().identifierTable;
+    LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable();
+
+    const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c);
+    if (iter != literalIdentifierTable.end())
+        return iter->second;
+
+    UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first;
+    literalIdentifierTable.add(c, addedString);
+
+    return addedString;
+}
+
+PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const char* c)
+{
+    if (!c) {
+        UString::Rep::null.hash();
+        return &UString::Rep::null;
+    }
+
+    if (!c[0]) {
+        UString::Rep::empty.hash();
+        return &UString::Rep::empty;
+    }
+
+    IdentifierTable& identifierTable = *globalData->identifierTable;
+    LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable();
 
-    const LiteralIdentifierTable::iterator& iter = literalTableLocalRef.find(c);
-    if (iter != literalTableLocalRef.end())
+    const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c);
+    if (iter != literalIdentifierTable.end())
         return iter->second;
 
-    UString::Rep* addedString = *identifierTable().add<const char*, CStringTranslator>(c).first;
-    literalTableLocalRef.add(c, addedString);
+    UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first;
+    literalIdentifierTable.add(c, addedString);
 
     return addedString;
 }
@@ -206,7 +213,7 @@ PassRefPtr<UString::Rep> Identifier::add(const UChar *s, int length)
     }
     
     UCharBuffer buf = {s, length}; 
-    return *identifierTable().add<UCharBuffer, UCharBufferTranslator>(buf).first;
+    return *JSGlobalData::threadInstance().identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf).first;
 }
 
 PassRefPtr<UString::Rep> Identifier::addSlowCase(UString::Rep *r)
@@ -218,7 +225,7 @@ PassRefPtr<UString::Rep> Identifier::addSlowCase(UString::Rep *r)
         return &UString::Rep::empty;
     }
 
-    return *identifierTable().add(r).first;
+    return *JSGlobalData::threadInstance().identifierTable->add(r).first;
 }
 
 void Identifier::remove(UString::Rep *r)
index 4a656b3a7a6e5cb72e79aca1f6832c0956ffd0f9..8198a6ea1545121902e5e57758c8dec67997a3da 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef KJS_IDENTIFIER_H
 #define KJS_IDENTIFIER_H
 
+#include "JSGlobalData.h"
 #include "ustring.h"
 
 namespace KJS {
@@ -34,6 +35,8 @@ namespace KJS {
         explicit Identifier(UString::Rep* rep) : _ustring(add(rep)) { } 
         explicit Identifier(const UString& s) : _ustring(add(s.rep())) { }
 
+        Identifier(JSGlobalData* globalData, const char* s) : _ustring(add(globalData, s)) { } // Only to be used with string literals.
+
         // Special constructor for cases where we overwrite an object in place.
         Identifier(PlacementNewAdoptType) : _ustring(PlacementNewAdopt) { }
         
@@ -79,6 +82,7 @@ namespace KJS {
         static bool equal(const Identifier& a, const char* b)
             { return equal(a._ustring.rep(), b); }
         
+        static PassRefPtr<UString::Rep> add(JSGlobalData*, const char*);
         static PassRefPtr<UString::Rep> add(const UChar*, int length);
         static PassRefPtr<UString::Rep> add(UString::Rep* r)
         {
@@ -98,6 +102,9 @@ namespace KJS {
     inline bool operator==(const Identifier& a, const char* b)
         { return Identifier::equal(a, b); }
 
+    IdentifierTable* createIdentifierTable();
+    void deleteIdentifierTable(IdentifierTable*);
+
 } // namespace KJS
 
 #endif // KJS_IDENTIFIER_H
index 51dd2cad00d767340c3c60aed82484b8fbe1aa2a..df4d5e0f5ae4f040a3113f8f41d650ddcc9269fc 100644 (file)
@@ -49,7 +49,7 @@ Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, i
     int errLine;
     UString errMsg;
 
-    RefPtr<ProgramNode> progNode = parser().parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, 0, &errLine, &errMsg);
+    RefPtr<ProgramNode> progNode = exec->parser()->parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, 0, &errLine, &errMsg);
     if (!progNode)
         return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, 0, sourceURL));
     return Completion(Normal);
@@ -69,7 +69,7 @@ Completion Interpreter::evaluate(ExecState* exec, ScopeChain& scopeChain, const
     int errLine;
     UString errMsg;
 
-    RefPtr<ProgramNode> programNode = parser().parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, &sourceId, &errLine, &errMsg);
+    RefPtr<ProgramNode> programNode = exec->parser()->parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, &sourceId, &errLine, &errMsg);
 
     // no program node means a syntax error occurred
     if (!programNode)
index e79d18e5893f3d65bcc99cc7d5b2a4c4a3beb557..b3fcdb81e52b265d62129ec21164a7becb61e2ec 100644 (file)
 #include <wtf/Assertions.h>
 #include <wtf/unicode/Unicode.h>
 
-#if USE(MULTIPLE_THREADS)
-#include <wtf/ThreadSpecific.h>
-#endif
-
 using namespace WTF;
 using namespace Unicode;
 
@@ -51,9 +47,9 @@ using namespace KJS;
 #include "lexer.lut.h"
 
 // a bridge for yacc from the C world to C++
-int kjsyylex(void* lvalp, void* llocp, void* lexer)
+int kjsyylex(void* lvalp, void* llocp, void* globalData)
 {
-  return static_cast<Lexer*>(lexer)->lex(lvalp, llocp);
+    return static_cast<JSGlobalData*>(globalData)->lexer->lex(lvalp, llocp);
 }
 
 namespace KJS {
@@ -63,17 +59,6 @@ static bool isDecimalDigit(int);
 static const size_t initialReadBufferCapacity = 32;
 static const size_t initialStringTableCapacity = 64;
 
-Lexer& lexer()
-{
-#if USE(MULTIPLE_THREADS)
-    static ThreadSpecific<Lexer> staticLexer;
-    return *staticLexer;
-#else
-    static Lexer staticLexer;
-    return staticLexer;
-#endif
-}
-
 Lexer::Lexer()
     : yylineno(1)
     , restrKeyword(false)
index 673e787f46a976dfea380b6827fdc007b0c81e03..740118570c1acbc01cb3f6fd42ddc15e87c422b1 100644 (file)
 #include <wtf/Vector.h>
 #include "SourceRange.h"
 
-namespace WTF {
-    template<typename T> class ThreadSpecific;
-}
-
 namespace KJS {
 
   class Identifier;
@@ -94,8 +90,7 @@ namespace KJS {
     SourceRange sourceRange(int openBrace, int closeBrace) { return SourceRange(m_source, openBrace + 1, closeBrace); }
 
   private:
-    friend Lexer& lexer();
-    friend class WTF::ThreadSpecific<Lexer>;
+    friend struct JSGlobalData;
     Lexer();
     ~Lexer();
 
@@ -153,8 +148,6 @@ namespace KJS {
 
     const HashTable mainTable;
   };
-  
-  Lexer& lexer(); // Returns the singletone JavaScript lexer.
 
 } // namespace KJS
 
index 67e46a43ec2f51b6af2f669483863ecf304b3a6a..7877b7fe6aad80dd889840bfb3234e3e6aba341b 100644 (file)
@@ -193,13 +193,13 @@ void ParserRefCounted::deleteNewObjects()
 Node::Node()
     : m_expectedReturnType(ObjectType)
 {
-    m_line = lexer().lineNo();
+    m_line = JSGlobalData::threadInstance().lexer->lineNo();
 }
 
 Node::Node(JSType expectedReturn)
     : m_expectedReturnType(expectedReturn)
 {
-    m_line = lexer().lineNo();
+    m_line = JSGlobalData::threadInstance().lexer->lineNo();
 }
 
 static void substitute(UString& string, const UString& substring) KJS_FAST_CALL;
@@ -443,7 +443,7 @@ RegisterID* EvalFunctionCallNode::emitCode(CodeGenerator& generator, RegisterID*
 {
     RefPtr<RegisterID> base = generator.tempDestination(dst);
     RegisterID* func = generator.newTemporary();
-    generator.emitResolveWithBase(base.get(), func, CommonIdentifiers::shared()->eval);
+    generator.emitResolveWithBase(base.get(), func, generator.propertyNames().eval);
     return generator.emitCallEval(generator.finalDestination(dst, base.get()), func, base.get(), m_args.get());
 }
 
@@ -1721,8 +1721,8 @@ RegisterID* TryNode::emitCode(CodeGenerator& generator, RegisterID* dst)
 
 ScopeNode::ScopeNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     : BlockNode(children)
-    , m_sourceURL(parser().sourceURL())
-    , m_sourceId(parser().sourceId())
+    , m_sourceURL(JSGlobalData::threadInstance().parser->sourceURL())
+    , m_sourceId(JSGlobalData::threadInstance().parser->sourceId())
     , m_usesEval(usesEval)
     , m_needsClosure(needsClosure)
 {
index f09c8579638f73091722a30d1662292d5689f41f..9ebc7f32c439d060a5db714148f0813a387cf1dd 100644 (file)
@@ -275,7 +275,7 @@ static bool prettyPrintScript(ExecState* exec, const UString& fileName, const Ve
     int errLine = 0;
     UString errMsg;
     UString scriptUString(script.data());
-    RefPtr<ProgramNode> programNode = parser().parse<ProgramNode>(exec, fileName, 1, UStringSourceProvider::create(scriptUString), 0, &errLine, &errMsg);
+    RefPtr<ProgramNode> programNode = exec->parser()->parse<ProgramNode>(exec, fileName, 1, UStringSourceProvider::create(scriptUString), 0, &errLine, &errMsg);
     if (!programNode) {
         fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str());
         return false;