Changeset 58012 in webkit
- Timestamp:
- Apr 21, 2010 1:59:14 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSContextRef.cpp
r58001 r58012 47 47 { 48 48 initializeThreading(); 49 return toRef(JSGlobalData::createNonDefault( ).releaseRef());49 return toRef(JSGlobalData::createNonDefault(ThreadStackTypeSmall).releaseRef()); 50 50 } 51 51 … … 85 85 86 86 JSLock lock(LockForReal); 87 RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createNonDefault( );87 RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createNonDefault(ThreadStackTypeSmall); 88 88 89 89 APIEntryShim entryShim(globalData.get(), false); -
trunk/JavaScriptCore/ChangeLog
r58010 r58012 1 2010-04-21 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Geoffrey Garen. 4 5 Fix for https://bugs.webkit.org/show_bug.cgi?id=37937 6 Wean JavaScriptCore off calls to isMainThread() 7 8 - Replace use of isMainThread() for interpreter reentry checks 9 with a stored value on the JSGlobalData. 10 - Replace use of isMainThread() for useMainThread only check in the 11 collector with a stored exclusive thread. 12 13 * API/JSContextRef.cpp: 14 (JSContextGroupCreate): 15 Always default to a small stack type for uses of the JSC API. It is 16 unlikely that the interpreter reentry required on the web will be as 17 important for other uses of JavaScriptCore. 18 19 * JavaScriptCore.exp: 20 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 21 Update exports. 22 23 * interpreter/Interpreter.cpp: 24 (JSC::Interpreter::execute): 25 (JSC::Interpreter::prepareForRepeatCall): 26 Use new stored JSGlobalData::maxReentryDepth instead of isMainThread(). 27 28 * interpreter/Interpreter.h: 29 Rename MaxMainThreadReentryDepth to MaxLargeThreadReentryDepth and 30 MaxSecondaryThreadReentryDepth to MaxSmallThreadReentryDepth. 31 32 * jsc.cpp: 33 (main): Use the a large stack for jsc since it is always using the 34 main thread. 35 36 * runtime/ArrayPrototype.cpp: 37 (JSC::arrayProtoFuncToString): 38 (JSC::arrayProtoFuncToLocaleString): 39 (JSC::arrayProtoFuncJoin): 40 Use new stored JSGlobalData::maxReentryDepth instead of isMainThread(). 41 42 * runtime/Collector.cpp: 43 (JSC::Heap::registerThread): 44 Use the concept of making JSC run on an exclusiveThread instead of 45 forcing a mainThreadOnly assertion. 46 47 * runtime/JSGlobalData.cpp: 48 (JSC::JSGlobalData::JSGlobalData): 49 (JSC::JSGlobalData::createNonDefault): 50 (JSC::JSGlobalData::create): 51 (JSC::JSGlobalData::createLeaked): 52 (JSC::JSGlobalData::sharedInstance): 53 * runtime/JSGlobalData.h: 54 Add ThreadStackType argument to JSGlobalData constructors and set 55 maxReentryDepth based on it. 56 1 57 2010-04-21 Gavin Barraclough <barraclough@apple.com> 2 58 -
trunk/JavaScriptCore/JavaScriptCore.exp
r58001 r58012 121 121 __ZN3JSC12JSGlobalData10ClientDataD2Ev 122 122 __ZN3JSC12JSGlobalData11jsArrayVPtrE 123 __ZN3JSC12JSGlobalData12createLeakedE v123 __ZN3JSC12JSGlobalData12createLeakedENS_15ThreadStackTypeE 124 124 __ZN3JSC12JSGlobalData12jsStringVPtrE 125 125 __ZN3JSC12JSGlobalData12stopSamplingEv … … 128 128 __ZN3JSC12JSGlobalData14resetDateCacheEv 129 129 __ZN3JSC12JSGlobalData14sharedInstanceEv 130 __ZN3JSC12JSGlobalData6createE v130 __ZN3JSC12JSGlobalData6createENS_15ThreadStackTypeE 131 131 __ZN3JSC12JSGlobalDataD1Ev 132 132 __ZN3JSC12SamplingTool5setupEv -
trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r58010 r58012 103 103 ?convertUTF8ToUTF16@Unicode@WTF@@YA?AW4ConversionResult@12@PAPBDPBDPAPA_WPA_W_N@Z 104 104 ?create@ByteArray@WTF@@SA?AV?$PassRefPtr@VByteArray@WTF@@@2@I@Z 105 ?create@JSGlobalData@JSC@@SA?AV?$PassRefPtr@VJSGlobalData@JSC@@@WTF@@ XZ105 ?create@JSGlobalData@JSC@@SA?AV?$PassRefPtr@VJSGlobalData@JSC@@@WTF@@W4ThreadStackType@2@@Z 106 106 ?create@OpaqueJSString@@SA?AV?$PassRefPtr@UOpaqueJSString@@@WTF@@ABVUString@JSC@@@Z 107 107 ?create@StringImpl@WebCore@@SA?AV?$PassRefPtr@VStringImpl@WebCore@@@WTF@@PBD@Z … … 111 111 ?createInheritorID@JSObject@JSC@@AAEPAVStructure@2@XZ 112 112 ?createInterruptedExecutionException@JSC@@YA?AVJSValue@1@PAVJSGlobalData@1@@Z 113 ?createLeaked@JSGlobalData@JSC@@SA?AV?$PassRefPtr@VJSGlobalData@JSC@@@WTF@@ XZ113 ?createLeaked@JSGlobalData@JSC@@SA?AV?$PassRefPtr@VJSGlobalData@JSC@@@WTF@@W4ThreadStackType@2@@Z 114 114 ?createSingleCharacterString@SmallStrings@JSC@@AAEXPAVJSGlobalData@2@E@Z 115 115 ?createStackOverflowError@JSC@@YA?AVJSValue@1@PAVExecState@1@@Z -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r57955 r58012 581 581 ASSERT(!scopeChain->globalData->exception); 582 582 583 if (m_reentryDepth >= MaxS econdaryThreadReentryDepth) {584 if ( !isMainThread() || m_reentryDepth >= MaxMainThreadReentryDepth) {583 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { 584 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) { 585 585 *exception = createStackOverflowError(callFrame); 586 586 return jsNull(); … … 642 642 ASSERT(!scopeChain->globalData->exception); 643 643 644 if (m_reentryDepth >= MaxS econdaryThreadReentryDepth) {645 if ( !isMainThread() || m_reentryDepth >= MaxMainThreadReentryDepth) {644 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { 645 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) { 646 646 *exception = createStackOverflowError(callFrame); 647 647 return jsNull(); … … 704 704 ASSERT(!scopeChain->globalData->exception); 705 705 706 if (m_reentryDepth >= MaxS econdaryThreadReentryDepth) {707 if ( !isMainThread() || m_reentryDepth >= MaxMainThreadReentryDepth) {706 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { 707 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) { 708 708 *exception = createStackOverflowError(callFrame); 709 709 return CallFrameClosure(); … … 780 780 ASSERT(!scopeChain->globalData->exception); 781 781 782 if (m_reentryDepth >= MaxS econdaryThreadReentryDepth) {783 if ( !isMainThread() || m_reentryDepth >= MaxMainThreadReentryDepth) {782 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { 783 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) { 784 784 *exception = createStackOverflowError(callFrame); 785 785 return jsNull(); -
trunk/JavaScriptCore/interpreter/Interpreter.h
r49409 r58012 65 65 }; 66 66 67 enum { Max MainThreadReentryDepth = 256, MaxSecondaryThreadReentryDepth = 32 };67 enum { MaxLargeThreadReentryDepth = 256, MaxSmallThreadReentryDepth = 32 }; 68 68 69 69 class Interpreter : public FastAllocBase { -
trunk/JavaScriptCore/jsc.cpp
r57318 r58012 347 347 // Structured Exception Handling 348 348 int res = 0; 349 JSGlobalData* globalData = JSGlobalData::create( ).releaseRef();349 JSGlobalData* globalData = JSGlobalData::create(ThreadStackTypeLarge).releaseRef(); 350 350 TRY 351 351 res = jscmain(argc, argv, globalData); -
trunk/JavaScriptCore/runtime/ArrayPrototype.cpp
r57978 r58012 157 157 158 158 HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; 159 if (arrayVisitedElements.size() >= MaxS econdaryThreadReentryDepth) {160 if ( !isMainThread() || arrayVisitedElements.size() >= MaxMainThreadReentryDepth)161 return throwError(exec, RangeError, "Maximum call stack size exceeded."); 159 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 160 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 161 return throwError(exec, RangeError, "Maximum call stack size exceeded."); 162 162 } 163 163 … … 215 215 216 216 HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; 217 if (arrayVisitedElements.size() >= MaxS econdaryThreadReentryDepth) {218 if ( !isMainThread() || arrayVisitedElements.size() >= MaxMainThreadReentryDepth)219 return throwError(exec, RangeError, "Maximum call stack size exceeded."); 217 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 218 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 219 return throwError(exec, RangeError, "Maximum call stack size exceeded."); 220 220 } 221 221 … … 253 253 254 254 HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; 255 if (arrayVisitedElements.size() >= MaxS econdaryThreadReentryDepth) {256 if ( !isMainThread() || arrayVisitedElements.size() >= MaxMainThreadReentryDepth)257 return throwError(exec, RangeError, "Maximum call stack size exceeded."); 255 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 256 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 257 return throwError(exec, RangeError, "Maximum call stack size exceeded."); 258 258 } 259 259 -
trunk/JavaScriptCore/runtime/Collector.cpp
r57025 r58012 639 639 void Heap::registerThread() 640 640 { 641 ASSERT(!m_globalData-> mainThreadOnly || isMainThread());641 ASSERT(!m_globalData->exclusiveThread || m_globalData->exclusiveThread == currentThread()); 642 642 643 643 if (!m_currentThreadRegistrar || pthread_getspecific(m_currentThreadRegistrar)) -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r57879 r58012 104 104 } 105 105 106 JSGlobalData::JSGlobalData(bool isShared )106 JSGlobalData::JSGlobalData(bool isShared, ThreadStackType threadStackType) 107 107 : isSharedInstance(isShared) 108 108 , clientData(0) … … 147 147 , cachedUTCOffset(NaN) 148 148 , weakRandom(static_cast<int>(currentTime())) 149 , maxReentryDepth(threadStackType == ThreadStackTypeSmall ? MaxSmallThreadReentryDepth : MaxLargeThreadReentryDepth) 149 150 #ifndef NDEBUG 150 , mainThreadOnly(false)151 , exclusiveThread(0) 151 152 #endif 152 153 { … … 197 198 } 198 199 199 PassRefPtr<JSGlobalData> JSGlobalData::createNonDefault( )200 { 201 return adoptRef(new JSGlobalData(false ));202 } 203 204 PassRefPtr<JSGlobalData> JSGlobalData::create( )205 { 206 JSGlobalData* globalData = new JSGlobalData(false );200 PassRefPtr<JSGlobalData> JSGlobalData::createNonDefault(ThreadStackType type) 201 { 202 return adoptRef(new JSGlobalData(false, type)); 203 } 204 205 PassRefPtr<JSGlobalData> JSGlobalData::create(ThreadStackType type) 206 { 207 JSGlobalData* globalData = new JSGlobalData(false, type); 207 208 wtfThreadData().initializeIdentifierTable(globalData->identifierTable); 208 209 return adoptRef(globalData); 209 210 } 210 211 211 PassRefPtr<JSGlobalData> JSGlobalData::createLeaked( )212 PassRefPtr<JSGlobalData> JSGlobalData::createLeaked(ThreadStackType type) 212 213 { 213 214 Structure::startIgnoringLeaks(); 214 RefPtr<JSGlobalData> data = create( );215 RefPtr<JSGlobalData> data = create(type); 215 216 Structure::stopIgnoringLeaks(); 216 217 return data.release(); … … 226 227 JSGlobalData*& instance = sharedInstanceInternal(); 227 228 if (!instance) { 228 instance = new JSGlobalData(true );229 instance = new JSGlobalData(true, ThreadStackTypeSmall); 229 230 #if ENABLE(JSC_MULTIPLE_THREADS) 230 231 instance->makeUsableFromMultipleThreads(); -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r57192 r58012 85 85 }; 86 86 87 enum ThreadStackType { 88 ThreadStackTypeLarge, 89 ThreadStackTypeSmall 90 }; 91 87 92 class JSGlobalData : public RefCounted<JSGlobalData> { 88 93 public: … … 94 99 static JSGlobalData& sharedInstance(); 95 100 96 static PassRefPtr<JSGlobalData> create( );97 static PassRefPtr<JSGlobalData> createLeaked( );98 static PassRefPtr<JSGlobalData> createNonDefault( );101 static PassRefPtr<JSGlobalData> create(ThreadStackType); 102 static PassRefPtr<JSGlobalData> createLeaked(ThreadStackType); 103 static PassRefPtr<JSGlobalData> createNonDefault(ThreadStackType); 99 104 ~JSGlobalData(); 100 105 … … 188 193 WeakRandom weakRandom; 189 194 195 int maxReentryDepth; 190 196 #ifndef NDEBUG 191 bool mainThreadOnly;197 ThreadIdentifier exclusiveThread; 192 198 #endif 193 199 … … 198 204 void dumpSampleData(ExecState* exec); 199 205 private: 200 JSGlobalData(bool isShared );206 JSGlobalData(bool isShared, ThreadStackType); 201 207 static JSGlobalData*& sharedInstanceInternal(); 202 208 void createNativeThunk(); -
trunk/WebCore/ChangeLog
r58006 r58012 1 2010-04-21 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Geoffrey Garen. 4 5 Fix for https://bugs.webkit.org/show_bug.cgi?id=37937 6 Wean JavaScriptCore off calls to isMainThread() 7 8 No change in behavior. 9 10 * bindings/js/JSDOMWindowBase.cpp: 11 (WebCore::JSDOMWindowBase::commonJSGlobalData): 12 Explicitly set a large stack type for the common JSGlobalData and 13 set the currently running thread as the exclusive thread for its 14 execution. 15 16 * bindings/js/WorkerScriptController.cpp: 17 (WebCore::WorkerScriptController::WorkerScriptController): 18 Explicitly set a small stack type for the workers JSGlobalData. 19 1 20 2010-04-21 Gavin Barraclough <barraclough@apple.com> 2 21 -
trunk/WebCore/bindings/js/JSDOMWindowBase.cpp
r57379 r58012 37 37 #include "Settings.h" 38 38 #include "WebCoreJSClientData.h" 39 #include <wtf/Threading.h> 39 40 #include <wtf/text/CString.h> 40 41 … … 157 158 static JSGlobalData* globalData = 0; 158 159 if (!globalData) { 159 globalData = JSGlobalData::createLeaked( ).releaseRef();160 globalData = JSGlobalData::createLeaked(ThreadStackTypeLarge).releaseRef(); 160 161 globalData->timeoutChecker.setTimeoutInterval(10000); // 10 seconds 161 162 #ifndef NDEBUG 162 globalData-> mainThreadOnly = true;163 globalData->exclusiveThread = currentThread(); 163 164 #endif 164 165 initNormalWorldClientData(globalData); -
trunk/WebCore/bindings/js/WorkerScriptController.cpp
r57379 r58012 49 49 50 50 WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) 51 : m_globalData(JSGlobalData::create( ))51 : m_globalData(JSGlobalData::create(ThreadStackTypeSmall)) 52 52 , m_workerContext(workerContext) 53 53 , m_executionForbidden(false)
Note: See TracChangeset
for help on using the changeset viewer.