Changeset 34412 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Jun 6, 2008, 11:03:24 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/CommonIdentifiers.cpp
r33979 r34412 22 22 #include "CommonIdentifiers.h" 23 23 24 #if USE(MULTIPLE_THREADS)25 #include <wtf/ThreadSpecific.h>26 using namespace WTF;27 #endif28 29 24 namespace KJS { 30 25 31 26 const char* const nullCString = 0; 32 27 33 #define INITIALIZE_PROPERTY_NAME(name) , name ( #name)28 #define INITIALIZE_PROPERTY_NAME(name) , name(globalData, #name) 34 29 35 CommonIdentifiers::CommonIdentifiers( )36 : nullIdentifier( nullCString)37 , underscoreProto( "__proto__")38 , thisIdentifier( "this")30 CommonIdentifiers::CommonIdentifiers(JSGlobalData* globalData) 31 : nullIdentifier(globalData, nullCString) 32 , underscoreProto(globalData, "__proto__") 33 , thisIdentifier(globalData, "this") 39 34 KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME) 40 35 { 41 36 } 42 37 43 CommonIdentifiers* CommonIdentifiers::shared()44 {45 #if USE(MULTIPLE_THREADS)46 static ThreadSpecific<CommonIdentifiers> sharedInstance;47 return sharedInstance;48 #else49 static CommonIdentifiers sharedInstance;50 return &sharedInstance;51 #endif52 }53 54 38 } // namespace KJS -
trunk/JavaScriptCore/kjs/CommonIdentifiers.h
r33979 r34412 24 24 #include "identifier.h" 25 25 #include <wtf/Noncopyable.h> 26 27 namespace WTF {28 template<typename T> class ThreadSpecific;29 }30 26 31 27 // List of property names, passed to a macro so we can do set them up various … … 75 71 76 72 private: 77 CommonIdentifiers( );78 friend class WTF::ThreadSpecific<CommonIdentifiers>;73 CommonIdentifiers(JSGlobalData*); 74 friend struct JSGlobalData; 79 75 80 76 public: 81 static CommonIdentifiers* shared();82 83 77 const Identifier nullIdentifier; 84 78 const Identifier underscoreProto; -
trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp
r34273 r34412 74 74 UString errMsg; 75 75 76 RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(&newExec, UString(), 1, UStringSourceProvider::create(script), &sourceId, &errLine, &errMsg);76 RefPtr<EvalNode> evalNode = newExec.parser()->parse<EvalNode>(&newExec, UString(), 1, UStringSourceProvider::create(script), &sourceId, &errLine, &errMsg); 77 77 78 78 if (!evalNode) -
trunk/JavaScriptCore/kjs/ExecState.cpp
r33979 r34412 36 36 , m_globalThisValue(globalThisValue) 37 37 , m_exception(0) 38 , m_ perThreadData(globalObject->perThreadData())38 , m_globalData(globalObject->globalData()) 39 39 , m_prev(0) 40 40 , m_machine(0) … … 49 49 , m_globalThisValue(exec->m_globalThisValue) 50 50 , m_exception(0) 51 , m_ perThreadData(exec->m_globalObject->perThreadData())51 , m_globalData(exec->m_globalData) 52 52 , m_prev(exec) 53 53 , m_machine(machine) -
trunk/JavaScriptCore/kjs/ExecState.h
r34355 r34412 25 25 #define ExecState_h 26 26 27 #include "JSGlobalData.h" 27 28 #include "LabelStack.h" 28 29 #include "LocalStorageEntry.h" … … 33 34 namespace KJS { 34 35 35 class CommonIdentifiers;36 36 class EvalNode; 37 37 class FunctionBodyNode; 38 38 class FunctionImp; 39 39 class GlobalFuncImp; 40 struct HashTable;41 40 class Interpreter; 42 41 class JSGlobalObject; … … 49 48 struct Instruction; 50 49 51 struct PerThreadData {52 const HashTable* arrayTable;53 const HashTable* dateTable;54 const HashTable* mathTable;55 const HashTable* numberTable;56 const HashTable* RegExpImpTable;57 const HashTable* RegExpObjectImpTable;58 const HashTable* stringTable;59 60 CommonIdentifiers* propertyNames;61 List emptyList;62 };63 64 50 // Represents the current state of script execution. 65 51 // Passed as the first argument to most functions. … … 92 78 bool hadException() const { return !!m_exception; } 93 79 94 // These pointers are used to avoid accessing global variables for these, 95 // to avoid taking PIC branches in Mach-O binaries. 96 const CommonIdentifiers& propertyNames() const { return *m_perThreadData->propertyNames; } 97 const List& emptyList() const { return m_perThreadData->emptyList; } 98 static const HashTable* arrayTable(ExecState* exec) { return exec->m_perThreadData->arrayTable; } 99 static const HashTable* dateTable(ExecState* exec) { return exec->m_perThreadData->dateTable; } 100 static const HashTable* mathTable(ExecState* exec) { return exec->m_perThreadData->mathTable; } 101 static const HashTable* numberTable(ExecState* exec) { return exec->m_perThreadData->numberTable; } 102 static const HashTable* RegExpImpTable(ExecState* exec) { return exec->m_perThreadData->RegExpImpTable; } 103 static const HashTable* RegExpObjectImpTable(ExecState* exec) { return exec->m_perThreadData->RegExpObjectImpTable; } 104 static const HashTable* stringTable(ExecState* exec) { return exec->m_perThreadData->stringTable; } 80 JSGlobalData& globalData() { return *m_globalData; } 81 82 IdentifierTable* identifierTable() { return m_globalData->identifierTable; } 83 const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; } 84 const List& emptyList() const { return m_globalData->emptyList; } 85 Lexer* lexer() { return m_globalData->lexer; } 86 Parser* parser() { return m_globalData->parser; } 87 static const HashTable* arrayTable(ExecState* exec) { return exec->m_globalData->arrayTable; } 88 static const HashTable* dateTable(ExecState* exec) { return exec->m_globalData->dateTable; } 89 static const HashTable* mathTable(ExecState* exec) { return exec->m_globalData->mathTable; } 90 static const HashTable* numberTable(ExecState* exec) { return exec->m_globalData->numberTable; } 91 static const HashTable* RegExpImpTable(ExecState* exec) { return exec->m_globalData->RegExpImpTable; } 92 static const HashTable* RegExpObjectImpTable(ExecState* exec) { return exec->m_globalData->RegExpObjectImpTable; } 93 static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; } 105 94 106 95 private: … … 117 106 JSValue* m_exception; 118 107 119 const PerThreadData* m_perThreadData;108 JSGlobalData* m_globalData; 120 109 121 110 // These values are controlled by the machine. -
trunk/JavaScriptCore/kjs/InitializeThreading.cpp
r33038 r34412 35 35 #include "identifier.h" 36 36 #include "JSGlobalObject.h" 37 #include "lexer.h"38 #include "Parser.h"39 37 #include "ustring.h" 40 38 #include <wtf/Threading.h> … … 54 52 Collector::registerAsMainThread(); 55 53 #endif 54 JSGlobalData::threadInstance(); 56 55 UString::null(); 57 Identifier::initializeIdentifierThreading();58 CommonIdentifiers::shared();59 lexer();60 56 initDateMath(); 61 JSGlobalObject::threadClassInfoHashTables();62 JSGlobalObject::head();63 57 #endif 64 58 } -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r33980 r34412 45 45 #include "string_object.h" 46 46 47 #if USE(MULTIPLE_THREADS)48 #include <wtf/ThreadSpecific.h>49 using namespace WTF;50 #endif51 52 47 #if HAVE(SYS_TIME_H) 53 48 #include <sys/time.h> … … 63 58 64 59 namespace KJS { 65 66 extern const HashTable arrayTable;67 extern const HashTable dateTable;68 extern const HashTable mathTable;69 extern const HashTable numberTable;70 extern const HashTable RegExpImpTable;71 extern const HashTable RegExpObjectImpTable;72 extern const HashTable stringTable;73 60 74 61 // Default number of ticks before a timeout check should be done. … … 125 112 } 126 113 127 struct ThreadClassInfoHashTables {128 ThreadClassInfoHashTables()129 : arrayTable(KJS::arrayTable)130 , dateTable(KJS::dateTable)131 , mathTable(KJS::mathTable)132 , numberTable(KJS::numberTable)133 , RegExpImpTable(KJS::RegExpImpTable)134 , RegExpObjectImpTable(KJS::RegExpObjectImpTable)135 , stringTable(KJS::stringTable)136 {137 }138 139 ~ThreadClassInfoHashTables()140 {141 #if USE(MULTIPLE_THREADS)142 delete[] arrayTable.table;143 delete[] dateTable.table;144 delete[] mathTable.table;145 delete[] numberTable.table;146 delete[] RegExpImpTable.table;147 delete[] RegExpObjectImpTable.table;148 delete[] stringTable.table;149 #endif150 }151 152 #if USE(MULTIPLE_THREADS)153 HashTable arrayTable;154 HashTable dateTable;155 HashTable mathTable;156 HashTable numberTable;157 HashTable RegExpImpTable;158 HashTable RegExpObjectImpTable;159 HashTable stringTable;160 #else161 const HashTable& arrayTable;162 const HashTable& dateTable;163 const HashTable& mathTable;164 const HashTable& numberTable;165 const HashTable& RegExpImpTable;166 const HashTable& RegExpObjectImpTable;167 const HashTable& stringTable;168 #endif169 };170 171 ThreadClassInfoHashTables* JSGlobalObject::threadClassInfoHashTables()172 {173 #if USE(MULTIPLE_THREADS)174 static ThreadSpecific<ThreadClassInfoHashTables> sharedInstance;175 return sharedInstance;176 #else177 static ThreadClassInfoHashTables sharedInstance;178 return &sharedInstance;179 #endif180 }181 182 114 void JSGlobalObject::init(JSObject* thisValue) 183 115 { … … 199 131 d()->debugger = 0; 200 132 201 d()->perThreadData.arrayTable = &threadClassInfoHashTables()->arrayTable; 202 d()->perThreadData.dateTable = &threadClassInfoHashTables()->dateTable; 203 d()->perThreadData.mathTable = &threadClassInfoHashTables()->mathTable; 204 d()->perThreadData.numberTable = &threadClassInfoHashTables()->numberTable; 205 d()->perThreadData.RegExpImpTable = &threadClassInfoHashTables()->RegExpImpTable; 206 d()->perThreadData.RegExpObjectImpTable = &threadClassInfoHashTables()->RegExpObjectImpTable; 207 d()->perThreadData.stringTable = &threadClassInfoHashTables()->stringTable; 208 d()->perThreadData.propertyNames = CommonIdentifiers::shared(); 133 d()->globalData = &JSGlobalData::threadInstance(); 209 134 210 135 d()->globalExec.set(new ExecState(this, thisValue, d()->globalScopeChain.node())); -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r34143 r34412 24 24 #define KJS_GlobalObject_h 25 25 26 #include "JSGlobalData.h" 26 27 #include "JSVariableObject.h" 27 28 #include "RegisterFile.h" … … 72 73 class UriErrorPrototype; 73 74 struct ActivationStackNode; 74 struct ThreadClassInfoHashTables;75 75 76 76 typedef Vector<ExecState*, 16> ExecStateStack; … … 84 84 : JSVariableObjectData(&symbolTable, registerFileStack.globalBasePointer(), 0) 85 85 , globalScopeChain(globalObject, thisValue) 86 , globalExec(new ExecState(globalObject, thisValue, globalScopeChain.node()))87 86 { 88 87 } … … 143 142 unsigned pageGroupIdentifier; 144 143 145 PerThreadData perThreadData;144 JSGlobalData* globalData; 146 145 147 146 HashSet<ProgramCodeBlock*> codeBlocks; … … 176 175 virtual void defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunc); 177 176 178 // Linked list of all global objects.179 static JSGlobalObject* head() { return s_head; }177 // Per-thread linked list of all global objects. 178 static JSGlobalObject*& head() { return JSGlobalData::threadInstance().head; } 180 179 JSGlobalObject* next() { return d()->next; } 181 180 … … 260 259 261 260 // Per-thread hash tables, cached on the global object for faster access. 262 const PerThreadData* perThreadData() const { return &d()->perThreadData; } 263 264 // Initialize and/or retrieve per-thread hash tables - use perThreadData() for faster access instead. 265 static ThreadClassInfoHashTables* threadClassInfoHashTables(); 261 JSGlobalData* globalData() { return d()->globalData; } 266 262 267 263 void init(JSObject* thisValue); -
trunk/JavaScriptCore/kjs/Parser.cpp
r34273 r34412 29 29 #include "lexer.h" 30 30 #include <wtf/HashSet.h> 31 #if USE(MULTIPLE_THREADS)32 #include <wtf/ThreadSpecific.h>33 using namespace WTF;34 #endif35 31 #include <wtf/Vector.h> 36 32 … … 66 62 *errMsg = 0; 67 63 68 Lexer& lexer = KJS::lexer();64 Lexer& lexer = *JSGlobalData::threadInstance().lexer; 69 65 70 66 ASSERT(startingLineNumber > 0); … … 75 71 *sourceId = ++m_sourceId; 76 72 77 int parseError = kjsyyparse(& lexer);73 int parseError = kjsyyparse(&JSGlobalData::threadInstance()); 78 74 bool lexError = lexer.sawError(); 79 75 lexer.clear(); … … 102 98 } 103 99 104 Parser& parser()105 {106 #if USE(MULTIPLE_THREADS)107 static ThreadSpecific<Parser> staticParser;108 return *staticParser;109 #else110 static Parser staticParser;111 return staticParser;112 #endif113 }114 115 100 } // namespace KJS -
trunk/JavaScriptCore/kjs/Parser.h
r33979 r34412 33 33 #include <wtf/RefPtr.h> 34 34 35 namespace WTF {36 template<typename T> class ThreadSpecific;37 }38 39 35 namespace KJS { 40 36 … … 61 57 62 58 private: 63 friend Parser& parser();64 friend class WTF::ThreadSpecific<Parser>;59 friend struct JSGlobalData; 60 Parser(); 65 61 66 Parser(); // Use parser() instead.67 62 void parse(ExecState*, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source, 68 63 int* sourceId, int* errLine, UString* errMsg); … … 77 72 int m_lastLine; 78 73 }; 79 80 Parser& parser(); // Returns the singleton JavaScript parser.81 74 82 75 template <class ParsedNode> -
trunk/JavaScriptCore/kjs/function.cpp
r34355 r34412 166 166 167 167 if (static_cast<size_t>(index) >= body->parameters().size()) 168 return CommonIdentifiers::shared()->nullIdentifier;168 return JSGlobalData::threadInstance().propertyNames->nullIdentifier; 169 169 170 170 Identifier name = parameters[index]; … … 174 174 for (size_t i = index + 1; i < size; ++i) 175 175 if (parameters[i] == name) 176 return CommonIdentifiers::shared()->nullIdentifier;176 return JSGlobalData::threadInstance().propertyNames->nullIdentifier; 177 177 178 178 return name; … … 261 261 ASSERT(indexIsNumber && indexAsNumber < size); 262 262 263 _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier;263 _map[indexAsNumber] = JSGlobalData::threadInstance().propertyNames->nullIdentifier; 264 264 } 265 265 … … 575 575 UString errMsg; 576 576 577 RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(s), &sourceId, &errLine, &errMsg);577 RefPtr<EvalNode> evalNode = exec->parser()->parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(s), &sourceId, &errLine, &errMsg); 578 578 579 579 if (!evalNode) -
trunk/JavaScriptCore/kjs/function_object.cpp
r34334 r34412 164 164 UString errMsg; 165 165 RefPtr<SourceProvider> source = UStringSourceProvider::create(body); 166 RefPtr<FunctionBodyNode> functionBody = parser().parse<FunctionBodyNode>(exec, sourceURL, lineNumber, source, &sourceId, &errLine, &errMsg);166 RefPtr<FunctionBodyNode> functionBody = exec->parser()->parse<FunctionBodyNode>(exec, sourceURL, lineNumber, source, &sourceId, &errLine, &errMsg); 167 167 168 168 // No program node == syntax error - throw a syntax error -
trunk/JavaScriptCore/kjs/grammar.y
r34373 r34412 34 34 #include "lexer.h" 35 35 #include "internal.h" 36 #include "JSGlobalData.h" 36 37 #include "CommonIdentifiers.h" 37 38 #include "NodeInfo.h" … … 50 51 #endif 51 52 52 #define LEXER (static_cast<KJS::Lexer*>(lexer)) 53 54 int kjsyylex(void* lvalp, void* llocp, void* lexer); 53 int kjsyylex(void* lvalp, void* llocp, void* globalPtr); 55 54 int kjsyyerror(const char*); 56 55 static inline bool allowAutomaticSemicolon(KJS::Lexer&, int); 56 57 #define GLOBAL_DATA static_cast<JSGlobalData*>(globalPtr) 58 #define LEXER (GLOBAL_DATA->lexer) 57 59 58 60 #define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0) … … 67 69 static ExpressionNode* makePrefixNode(ExpressionNode* expr, Operator); 68 70 static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator); 69 static PropertyNode* makeGetterOrSetterPropertyNode( const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceRange&);70 static ExpressionNodeInfo makeFunctionCallNode( ExpressionNodeInfo func, ArgumentsNodeInfo);71 static PropertyNode* makeGetterOrSetterPropertyNode(void*, const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceRange&); 72 static ExpressionNodeInfo makeFunctionCallNode(void*, ExpressionNodeInfo func, ArgumentsNodeInfo); 71 73 static ExpressionNode* makeTypeOfNode(ExpressionNode*); 72 74 static ExpressionNode* makeDeleteNode(ExpressionNode*); … … 91 93 #endif 92 94 93 #define YYPARSE_PARAM lexer94 #define YYLEX_PARAM lexer95 #define YYPARSE_PARAM globalPtr 96 #define YYLEX_PARAM globalPtr 95 97 96 98 template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls, … … 303 305 | STRING ':' AssignmentExpr { $$ = createNodeFeatureInfo<PropertyNode*>(new PropertyNode(Identifier(*$1), $3.m_node, PropertyNode::Constant), $3.m_featureInfo); } 304 306 | NUMBER ':' AssignmentExpr { $$ = createNodeFeatureInfo<PropertyNode*>(new PropertyNode(Identifier(UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_featureInfo); } 305 | 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; }307 | 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; } 306 308 | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE 307 { $$ = createNodeFeatureInfo<PropertyNode*>(makeGetterOrSetterPropertyNode( *$1, *$2, $4.head, $7, LEXER->sourceRange($6, $8)), ClosureFeature); DBG($7, @6, @8); if (!$$.m_node) YYABORT; }309 { $$ = createNodeFeatureInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.head, $7, LEXER->sourceRange($6, $8)), ClosureFeature); DBG($7, @6, @8); if (!$$.m_node) YYABORT; } 308 310 ; 309 311 … … 385 387 386 388 CallExpr: 387 MemberExpr Arguments { $$ = makeFunctionCallNode( $1, $2); }388 | CallExpr Arguments { $$ = makeFunctionCallNode( $1, $2); }389 MemberExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2); } 390 | CallExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2); } 389 391 | CallExpr '[' Expr ']' { $$ = createNodeFeatureInfo<ExpressionNode*>(new BracketAccessorNode($1.m_node, $3.m_node, $3.m_featureInfo & AssignFeature), $1.m_featureInfo | $3.m_featureInfo); } 390 392 | CallExpr '.' IDENT { $$ = createNodeFeatureInfo<ExpressionNode*>(new DotAccessorNode($1.m_node, *$3), $1.m_featureInfo); } … … 392 394 393 395 CallExprNoBF: 394 MemberExprNoBF Arguments { $$ = makeFunctionCallNode( $1, $2); }395 | CallExprNoBF Arguments { $$ = makeFunctionCallNode( $1, $2); }396 MemberExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2); } 397 | CallExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2); } 396 398 | CallExprNoBF '[' Expr ']' { $$ = createNodeFeatureInfo<ExpressionNode*>(new BracketAccessorNode($1.m_node, $3.m_node, $3.m_featureInfo & AssignFeature), $1.m_featureInfo | $3.m_featureInfo); } 397 399 | CallExprNoBF '.' IDENT { $$ = createNodeFeatureInfo<ExpressionNode*>(new DotAccessorNode($1.m_node, *$3), $1.m_featureInfo); } … … 1002 1004 1003 1005 TryStatement: 1004 TRY Block FINALLY Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode($2.m_node, CommonIdentifiers::shared()->nullIdentifier, 0, $4.m_node),1006 TRY Block FINALLY Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode($2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, 0, $4.m_node), 1005 1007 mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations), 1006 1008 mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations), … … 1034 1036 1035 1037 FunctionExpr: 1036 FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode( CommonIdentifiers::shared()->nullIdentifier, $5, LEXER->sourceRange($4, $6)), ClosureFeature); DBG($5, @4, @6); }1037 | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode( CommonIdentifiers::shared()->nullIdentifier, $6, LEXER->sourceRange($5, $7), $3.head), ClosureFeature); DBG($6, @5, @7); }1038 FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(GLOBAL_DATA->propertyNames->nullIdentifier, $5, LEXER->sourceRange($4, $6)), ClosureFeature); DBG($5, @4, @6); } 1039 | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(GLOBAL_DATA->propertyNames->nullIdentifier, $6, LEXER->sourceRange($5, $7), $3.head), ClosureFeature); DBG($6, @5, @7); } 1038 1040 | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(*$2, $6, LEXER->sourceRange($5, $7)), ClosureFeature); DBG($6, @5, @7); } 1039 1041 | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeFeatureInfo(new FuncExprNode(*$2, $7, LEXER->sourceRange($6, $8), $4.head), ClosureFeature); DBG($7, @6, @8); } … … 1066 1068 1067 1069 Program: 1068 /* not in spec */ { parser().didFinishParsing(new SourceElements, 0, 0, false, false, @0.last_line); }1069 | SourceElements { parser().didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations,1070 /* not in spec */ { GLOBAL_DATA->parser->didFinishParsing(new SourceElements, 0, 0, false, false, @0.last_line); } 1071 | SourceElements { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, 1070 1072 ($1.m_featureInfo & EvalFeature) != 0, ($1.m_featureInfo & ClosureFeature) != 0, 1071 1073 @1.last_line); } … … 1182 1184 } 1183 1185 1184 static ExpressionNodeInfo makeFunctionCallNode( ExpressionNodeInfo func, ArgumentsNodeInfo args)1186 static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args) 1185 1187 { 1186 1188 FeatureInfo features = func.m_featureInfo | args.m_featureInfo; … … 1190 1192 ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node); 1191 1193 const Identifier& identifier = resolve->identifier(); 1192 if (identifier == CommonIdentifiers::shared()->eval)1194 if (identifier == GLOBAL_DATA->propertyNames->eval) 1193 1195 return createNodeFeatureInfo<ExpressionNode*>(new EvalFunctionCallNode(args.m_node), EvalFeature | features); 1194 1196 return createNodeFeatureInfo<ExpressionNode*>(new FunctionCallResolveNode(identifier, args.m_node), features); … … 1229 1231 } 1230 1232 1231 static PropertyNode* makeGetterOrSetterPropertyNode( const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceRange& source)1233 static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceRange& source) 1232 1234 { 1233 1235 PropertyNode::Type type; … … 1238 1240 else 1239 1241 return 0; 1240 return new PropertyNode(name, new FuncExprNode( CommonIdentifiers::shared()->nullIdentifier, body, source, params), type);1242 return new PropertyNode(name, new FuncExprNode(GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type); 1241 1243 } 1242 1244 … … 1292 1294 } 1293 1295 1296 #undef GLOBAL_DATA -
trunk/JavaScriptCore/kjs/identifier.cpp
r34361 r34412 29 29 #include <wtf/FastMalloc.h> 30 30 #include <wtf/HashSet.h> 31 #if USE(MULTIPLE_THREADS)32 #include <wtf/ThreadSpecific.h>33 using namespace WTF;34 #endif35 31 36 32 namespace KJS { 33 34 typedef HashMap<const char*, RefPtr<UString::Rep>, PtrHash<const char*> > LiteralIdentifierTable; 37 35 38 36 class IdentifierTable { … … 62 60 void remove(UString::Rep* r) { m_table.remove(r); } 63 61 62 LiteralIdentifierTable& literalTable() { return m_literalTable; } 63 64 64 private: 65 65 HashSet<UString::Rep*> m_table; 66 }; 67 68 typedef HashMap<const char*, RefPtr<UString::Rep>, PtrHash<const char*> > LiteralIdentifierTable; 69 70 static inline IdentifierTable& identifierTable() 71 { 72 #if USE(MULTIPLE_THREADS) 73 static ThreadSpecific<IdentifierTable> table; 74 return *table; 75 #else 76 static IdentifierTable table; 77 return table; 78 #endif 79 } 80 81 static inline LiteralIdentifierTable& literalIdentifierTable() 82 { 83 #if USE(MULTIPLE_THREADS) 84 static ThreadSpecific<LiteralIdentifierTable> table; 85 return *table; 86 #else 87 static LiteralIdentifierTable table; 88 return table; 89 #endif 90 } 91 92 void Identifier::initializeIdentifierThreading() 93 { 94 identifierTable(); 95 literalIdentifierTable(); 66 LiteralIdentifierTable m_literalTable; 67 }; 68 69 IdentifierTable* createIdentifierTable() 70 { 71 return new IdentifierTable; 72 } 73 74 void deleteIdentifierTable(IdentifierTable* table) 75 { 76 delete table; 96 77 } 97 78 … … 156 137 } 157 138 158 LiteralIdentifierTable& literalTableLocalRef = literalIdentifierTable(); 159 160 const LiteralIdentifierTable::iterator& iter = literalTableLocalRef.find(c); 161 if (iter != literalTableLocalRef.end()) 139 IdentifierTable& identifierTable = *JSGlobalData::threadInstance().identifierTable; 140 LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable(); 141 142 const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c); 143 if (iter != literalIdentifierTable.end()) 162 144 return iter->second; 163 145 164 UString::Rep* addedString = *identifierTable().add<const char*, CStringTranslator>(c).first; 165 literalTableLocalRef.add(c, addedString); 146 UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first; 147 literalIdentifierTable.add(c, addedString); 148 149 return addedString; 150 } 151 152 PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const char* c) 153 { 154 if (!c) { 155 UString::Rep::null.hash(); 156 return &UString::Rep::null; 157 } 158 159 if (!c[0]) { 160 UString::Rep::empty.hash(); 161 return &UString::Rep::empty; 162 } 163 164 IdentifierTable& identifierTable = *globalData->identifierTable; 165 LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable(); 166 167 const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c); 168 if (iter != literalIdentifierTable.end()) 169 return iter->second; 170 171 UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first; 172 literalIdentifierTable.add(c, addedString); 166 173 167 174 return addedString; … … 207 214 208 215 UCharBuffer buf = {s, length}; 209 return * identifierTable().add<UCharBuffer, UCharBufferTranslator>(buf).first;216 return *JSGlobalData::threadInstance().identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf).first; 210 217 } 211 218 … … 219 226 } 220 227 221 return * identifierTable().add(r).first;228 return *JSGlobalData::threadInstance().identifierTable->add(r).first; 222 229 } 223 230 -
trunk/JavaScriptCore/kjs/identifier.h
r34361 r34412 22 22 #define KJS_IDENTIFIER_H 23 23 24 #include "JSGlobalData.h" 24 25 #include "ustring.h" 25 26 … … 34 35 explicit Identifier(UString::Rep* rep) : _ustring(add(rep)) { } 35 36 explicit Identifier(const UString& s) : _ustring(add(s.rep())) { } 37 38 Identifier(JSGlobalData* globalData, const char* s) : _ustring(add(globalData, s)) { } // Only to be used with string literals. 36 39 37 40 // Special constructor for cases where we overwrite an object in place. … … 80 83 { return equal(a._ustring.rep(), b); } 81 84 85 static PassRefPtr<UString::Rep> add(JSGlobalData*, const char*); 82 86 static PassRefPtr<UString::Rep> add(const UChar*, int length); 83 87 static PassRefPtr<UString::Rep> add(UString::Rep* r) … … 99 103 { return Identifier::equal(a, b); } 100 104 105 IdentifierTable* createIdentifierTable(); 106 void deleteIdentifierTable(IdentifierTable*); 107 101 108 } // namespace KJS 102 109 -
trunk/JavaScriptCore/kjs/interpreter.cpp
r34036 r34412 50 50 UString errMsg; 51 51 52 RefPtr<ProgramNode> progNode = parser().parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, 0, &errLine, &errMsg);52 RefPtr<ProgramNode> progNode = exec->parser()->parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, 0, &errLine, &errMsg); 53 53 if (!progNode) 54 54 return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, 0, sourceURL)); … … 70 70 UString errMsg; 71 71 72 RefPtr<ProgramNode> programNode = parser().parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, &sourceId, &errLine, &errMsg);72 RefPtr<ProgramNode> programNode = exec->parser()->parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, &sourceId, &errLine, &errMsg); 73 73 74 74 // no program node means a syntax error occurred -
trunk/JavaScriptCore/kjs/lexer.cpp
r34273 r34412 34 34 #include <wtf/unicode/Unicode.h> 35 35 36 #if USE(MULTIPLE_THREADS)37 #include <wtf/ThreadSpecific.h>38 #endif39 40 36 using namespace WTF; 41 37 using namespace Unicode; … … 52 48 53 49 // a bridge for yacc from the C world to C++ 54 int kjsyylex(void* lvalp, void* llocp, void* lexer)55 { 56 return static_cast<Lexer*>(lexer)->lex(lvalp, llocp);50 int kjsyylex(void* lvalp, void* llocp, void* globalData) 51 { 52 return static_cast<JSGlobalData*>(globalData)->lexer->lex(lvalp, llocp); 57 53 } 58 54 … … 63 59 static const size_t initialReadBufferCapacity = 32; 64 60 static const size_t initialStringTableCapacity = 64; 65 66 Lexer& lexer()67 {68 #if USE(MULTIPLE_THREADS)69 static ThreadSpecific<Lexer> staticLexer;70 return *staticLexer;71 #else72 static Lexer staticLexer;73 return staticLexer;74 #endif75 }76 61 77 62 Lexer::Lexer() -
trunk/JavaScriptCore/kjs/lexer.h
r33979 r34412 29 29 #include <wtf/Vector.h> 30 30 #include "SourceRange.h" 31 32 namespace WTF {33 template<typename T> class ThreadSpecific;34 }35 31 36 32 namespace KJS { … … 95 91 96 92 private: 97 friend Lexer& lexer(); 98 friend class WTF::ThreadSpecific<Lexer>; 93 friend struct JSGlobalData; 99 94 Lexer(); 100 95 ~Lexer(); … … 154 149 const HashTable mainTable; 155 150 }; 156 157 Lexer& lexer(); // Returns the singletone JavaScript lexer.158 151 159 152 } // namespace KJS -
trunk/JavaScriptCore/kjs/nodes.cpp
r34400 r34412 194 194 : m_expectedReturnType(ObjectType) 195 195 { 196 m_line = lexer().lineNo();196 m_line = JSGlobalData::threadInstance().lexer->lineNo(); 197 197 } 198 198 … … 200 200 : m_expectedReturnType(expectedReturn) 201 201 { 202 m_line = lexer().lineNo();202 m_line = JSGlobalData::threadInstance().lexer->lineNo(); 203 203 } 204 204 … … 444 444 RefPtr<RegisterID> base = generator.tempDestination(dst); 445 445 RegisterID* func = generator.newTemporary(); 446 generator.emitResolveWithBase(base.get(), func, CommonIdentifiers::shared()->eval);446 generator.emitResolveWithBase(base.get(), func, generator.propertyNames().eval); 447 447 return generator.emitCallEval(generator.finalDestination(dst, base.get()), func, base.get(), m_args.get()); 448 448 } … … 1722 1722 ScopeNode::ScopeNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1723 1723 : BlockNode(children) 1724 , m_sourceURL( parser().sourceURL())1725 , m_sourceId( parser().sourceId())1724 , m_sourceURL(JSGlobalData::threadInstance().parser->sourceURL()) 1725 , m_sourceId(JSGlobalData::threadInstance().parser->sourceId()) 1726 1726 , m_usesEval(usesEval) 1727 1727 , m_needsClosure(needsClosure) -
trunk/JavaScriptCore/kjs/testkjs.cpp
r34273 r34412 276 276 UString errMsg; 277 277 UString scriptUString(script.data()); 278 RefPtr<ProgramNode> programNode = parser().parse<ProgramNode>(exec, fileName, 1, UStringSourceProvider::create(scriptUString), 0, &errLine, &errMsg);278 RefPtr<ProgramNode> programNode = exec->parser()->parse<ProgramNode>(exec, fileName, 1, UStringSourceProvider::create(scriptUString), 0, &errLine, &errMsg); 279 279 if (!programNode) { 280 280 fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str());
Note:
See TracChangeset
for help on using the changeset viewer.