Changeset 35853 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Aug 20, 2008, 12:23:06 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/AllInOneFile.cpp
r35478 r35853 62 62 #include "interpreter.cpp" 63 63 #include "JSImmediate.cpp" 64 #include "JSLock.cpp" 64 65 #include "JSWrapperObject.cpp" 65 66 #include "lexer.cpp" -
trunk/JavaScriptCore/kjs/JSGlobalData.cpp
r35815 r35853 33 33 #include "CommonIdentifiers.h" 34 34 #include "JSClassRef.h" 35 #include "JSLock.h" 35 36 #include "Machine.h" 36 37 #include "Parser.h" … … 56 57 extern const HashTable stringTable; 57 58 58 JSGlobalData::JSGlobalData( )59 JSGlobalData::JSGlobalData(bool isShared) 59 60 : machine(new Machine) 60 61 , heap(new Heap(this)) … … 85 86 , parser(new Parser) 86 87 , head(0) 88 , isSharedInstance(isShared) 87 89 { 88 90 } … … 91 93 { 92 94 delete heap; 93 heap = 0; // zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.94 95 delete machine; 96 #ifndef NDEBUG 97 // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance. 98 heap = 0; 95 99 machine = 0; 100 #endif 96 101 97 102 #if ENABLE(JSC_MULTIPLE_THREADS) … … 132 137 } 133 138 139 bool JSGlobalData::sharedInstanceExists() 140 { 141 return sharedInstanceInternal(); 134 142 } 143 144 JSGlobalData& JSGlobalData::sharedInstance() 145 { 146 JSGlobalData*& instance = sharedInstanceInternal(); 147 if (!instance) 148 instance = new JSGlobalData(true); 149 return *instance; 150 } 151 152 JSGlobalData*& JSGlobalData::sharedInstanceInternal() 153 { 154 ASSERT(JSLock::currentThreadIsHoldingLock()); 155 static JSGlobalData* sharedInstance; 156 return sharedInstance; 157 } 158 159 } -
trunk/JavaScriptCore/kjs/JSGlobalData.h
r35511 r35853 55 55 class JSGlobalData : public RefCounted<JSGlobalData> { 56 56 public: 57 static bool sharedInstanceExists(); 58 static JSGlobalData& sharedInstance(); 59 57 60 static PassRefPtr<JSGlobalData> create(); 58 61 ~JSGlobalData(); … … 83 86 JSGlobalObject* head; 84 87 88 bool isSharedInstance; 89 85 90 private: 86 JSGlobalData(); 91 JSGlobalData(bool isShared = false); 92 93 static JSGlobalData*& sharedInstanceInternal(); 87 94 }; 88 95 -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r35807 r35853 44 44 #include "GlobalEvalFunction.h" 45 45 #include "JSGlobalObjectFunctions.h" 46 #include "JSLock.h" 46 47 #include "Machine.h" 47 48 #include "MathObject.h" … … 79 80 JSGlobalObject::~JSGlobalObject() 80 81 { 82 ASSERT(JSLock::currentThreadIsHoldingLock()); 83 81 84 if (d()->debugger) 82 85 d()->debugger->detach(this); … … 110 113 void JSGlobalObject::init(JSObject* thisValue) 111 114 { 115 ASSERT(JSLock::currentThreadIsHoldingLock()); 116 112 117 d()->globalData = Heap::heap(this)->globalData(); 113 118 -
trunk/JavaScriptCore/kjs/Shell.cpp
r35807 r35853 31 31 #include "JSFunction.h" 32 32 #include "JSGlobalObject.h" 33 #include "JSLock.h" 33 34 #include "JSObject.h" 34 35 #include "Parser.h" … … 209 210 JSValue* functionGC(ExecState* exec, JSObject*, JSValue*, const ArgList&) 210 211 { 212 JSLock lock(false); 211 213 exec->heap()->collect(); 212 214 return jsUndefined(); … … 460 462 KJS::initializeThreading(); 461 463 464 JSLock lock(false); 465 462 466 Options options; 463 467 parseArguments(argc, argv, options); -
trunk/JavaScriptCore/kjs/collector.cpp
r35830 r35853 25 25 #include "ExecState.h" 26 26 #include "JSGlobalObject.h" 27 #include "JSLock.h" 27 28 #include "JSString.h" 28 29 #include "JSValue.h" … … 135 136 Heap::~Heap() 136 137 { 138 JSLock lock(false); 139 137 140 // The global object is not GC protected at this point, so sweeping may delete it (and thus the global data) 138 141 // before other objects that may use the global data. … … 274 277 275 278 CollectorHeap& heap = heapType == PrimaryHeap ? primaryHeap : numberHeap; 279 ASSERT(JSLock::lockCount() > 0); 280 ASSERT(JSLock::currentThreadIsHoldingLock()); 276 281 ASSERT(s <= HeapConstants<heapType>::cellSize); 277 282 UNUSED_PARAM(s); // s is now only used for the above assert … … 778 783 { 779 784 // Most clients do not need to call this, with the notable exception of WebCore. 780 // Clients that use context from a single context group from multiple threads are supposed785 // Clients that use shared heap have JSLock protection, while others are supposed 781 786 // to do explicit locking. WebCore violates this contract in Database code, 782 787 // which calls gcUnprotect from a secondary thread. … … 788 793 { 789 794 ASSERT(k); 795 ASSERT(JSLock::currentThreadIsHoldingLock() || !m_globalData->isSharedInstance); 790 796 791 797 if (JSImmediate::isImmediate(k)) … … 804 810 { 805 811 ASSERT(k); 812 ASSERT(JSLock::currentThreadIsHoldingLock() || !m_globalData->isSharedInstance); 806 813 807 814 if (JSImmediate::isImmediate(k)) … … 941 948 bool Heap::collect() 942 949 { 950 #ifndef NDEBUG 951 if (m_globalData->isSharedInstance) { 952 ASSERT(JSLock::lockCount() > 0); 953 ASSERT(JSLock::currentThreadIsHoldingLock()); 954 } 955 #endif 956 943 957 ASSERT((primaryHeap.operationInProgress == NoOperation) | (numberHeap.operationInProgress == NoOperation)); 944 958 if ((primaryHeap.operationInProgress != NoOperation) | (numberHeap.operationInProgress != NoOperation)) -
trunk/JavaScriptCore/kjs/interpreter.cpp
r35478 r35853 26 26 #include "ExecState.h" 27 27 #include "JSGlobalObject.h" 28 #include "JSLock.h" 28 29 #include "Machine.h" 29 30 #include "Parser.h" … … 46 47 Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source) 47 48 { 49 JSLock lock(exec); 50 48 51 int errLine; 49 52 UString errMsg; … … 62 65 Completion Interpreter::evaluate(ExecState* exec, ScopeChain& scopeChain, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source, JSValue* thisValue) 63 66 { 67 JSLock lock(exec); 68 64 69 // parse the source code 65 70 int sourceId;
Note:
See TracChangeset
for help on using the changeset viewer.