Changeset 76457 in webkit
- Timestamp:
- Jan 22, 2011 9:03:16 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r76454 r76457 1 2011-01-22 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 ASSERT running run-webkit-tests --threaded. 6 https://bugs.webkit.org/show_bug.cgi?id=52971 7 8 SunSpider and v8 report no change. 9 10 * runtime/ConservativeSet.cpp: 11 (JSC::ConservativeSet::grow): 12 (JSC::ConservativeSet::add): 13 * runtime/ConservativeSet.h: Tweaked the inline capacity to 128, and 14 the growth policy to 2X, to make SunSpider and v8 happy. 15 (JSC::ConservativeSet::ConservativeSet): 16 (JSC::ConservativeSet::~ConservativeSet): 17 (JSC::ConservativeSet::mark): Use OSAllocator directly, instead of malloc. 18 Malloc is forbidden during a multi-threaded mark phase because it can 19 cause deadlock. 20 1 21 2011-01-22 Geoffrey Garen <ggaren@apple.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/ConservativeSet.cpp
r76454 r76457 34 34 } 35 35 36 void ConservativeSet::grow() 37 { 38 size_t newCapacity = m_capacity == inlineCapacity ? nonInlineCapacity : m_capacity * 2; 39 JSCell** newSet = static_cast<JSCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(JSCell*))); 40 memcpy(newSet, m_set, m_size * sizeof(JSCell*)); 41 if (m_set != m_inlineSet) 42 OSAllocator::decommitAndRelease(m_set, m_capacity * sizeof(JSCell*)); 43 m_capacity = newCapacity; 44 m_set = newSet; 45 } 46 36 47 void ConservativeSet::add(void* begin, void* end) 37 48 { … … 44 55 if (!m_heap->contains(*it)) 45 56 continue; 46 m_vector.append(reinterpret_cast<JSCell*>(*it)); 57 58 if (m_size == m_capacity) 59 grow(); 60 61 m_set[m_size++] = reinterpret_cast<JSCell*>(*it); 47 62 } 48 63 } -
trunk/Source/JavaScriptCore/runtime/ConservativeSet.h
r76454 r76457 38 38 public: 39 39 ConservativeSet(Heap*); 40 ~ConservativeSet(); 40 41 41 42 void add(void* begin, void* end); … … 43 44 44 45 private: 46 static const size_t inlineCapacity = 128; 47 static const size_t nonInlineCapacity = 8192 / sizeof(JSCell*); 48 49 void grow(); 50 45 51 Heap* m_heap; 46 Vector<JSCell*, 64> m_vector; 52 JSCell** m_set; 53 size_t m_size; 54 size_t m_capacity; 55 JSCell* m_inlineSet[inlineCapacity]; 47 56 }; 48 57 49 58 inline ConservativeSet::ConservativeSet(Heap* heap) 50 59 : m_heap(heap) 60 , m_set(m_inlineSet) 61 , m_size(0) 62 , m_capacity(inlineCapacity) 51 63 { 64 } 65 66 inline ConservativeSet::~ConservativeSet() 67 { 68 if (m_set != m_inlineSet) 69 OSAllocator::decommitAndRelease(m_set, m_capacity * sizeof(JSCell*)); 52 70 } 53 71 54 72 inline void ConservativeSet::mark(MarkStack& markStack) 55 73 { 56 for (size_t i = 0; i < m_ vector.size(); ++i)57 markStack.append(m_ vector[i]);74 for (size_t i = 0; i < m_size; ++i) 75 markStack.append(m_set[i]); 58 76 } 59 77 -
trunk/Tools/ChangeLog
r76451 r76457 1 2011-01-22 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 Beefed up --threaded mode to catch even more kinds of errors. 6 https://bugs.webkit.org/show_bug.cgi?id=52971 7 8 * DumpRenderTree/pthreads/JavaScriptThreadingPthreads.cpp: Use a shared 9 context group to force JSC to mark multiple threads. (This used to be 10 the default, but it changed in SnowLeopard.) 11 (runJavaScriptThread): Do more locking and unlocking, and more allocation, 12 to give threading mistakes more chances to show themselves. 13 (startJavaScriptThreads): 14 (stopJavaScriptThreads): 15 1 16 2011-01-22 Robert Hogan <robert@webkit.org> 2 17 -
trunk/Tools/DumpRenderTree/pthreads/JavaScriptThreadingPthreads.cpp
r51336 r76457 38 38 #include <wtf/HashSet.h> 39 39 40 static JSContextGroupRef javaScriptThreadsGroup; 41 40 42 static pthread_mutex_t javaScriptThreadsMutex = PTHREAD_MUTEX_INITIALIZER; 41 43 static bool javaScriptThreadsShouldTerminate; … … 52 54 } 53 55 54 // Loops forever, running a script and randomly respawning, until55 // javaScriptThreadsShouldTerminate becomes true.56 // This function exercises JSC in a loop until javaScriptThreadsShouldTerminate 57 // becomes true or it probabilistically decides to spawn a replacement thread and exit. 56 58 void* runJavaScriptThread(void* arg) 57 59 { 58 const char* const script =60 static const char* const script = 59 61 "var array = [];" 60 "for (var i = 0; i < 10 ; i++) {"62 "for (var i = 0; i < 1024; i++) {" 61 63 " array.push(String(i));" 62 64 "}"; 63 65 66 pthread_mutex_lock(&javaScriptThreadsMutex); 67 JSGlobalContextRef ctx = JSGlobalContextCreateInGroup(javaScriptThreadsGroup, 0); 68 pthread_mutex_unlock(&javaScriptThreadsMutex); 69 70 pthread_mutex_lock(&javaScriptThreadsMutex); 71 JSStringRef scriptRef = JSStringCreateWithUTF8CString(script); 72 pthread_mutex_unlock(&javaScriptThreadsMutex); 73 64 74 while (1) { 65 JSGlobalContextRef ctx = JSGlobalContextCreate(0); 66 JSStringRef scriptRef = JSStringCreateWithUTF8CString(script); 67 75 pthread_mutex_lock(&javaScriptThreadsMutex); 68 76 JSValueRef exception = 0; 69 77 JSEvaluateScript(ctx, scriptRef, 0, 0, 1, &exception); 70 78 ASSERT(!exception); 71 72 JSGarbageCollect(ctx); 73 JSGlobalContextRelease(ctx); 74 JSStringRelease(scriptRef); 75 76 JSGarbageCollect(0); 79 pthread_mutex_unlock(&javaScriptThreadsMutex); 77 80 78 81 pthread_mutex_lock(&javaScriptThreadsMutex); 82 size_t valuesCount = 1024; 83 JSValueRef values[valuesCount]; 84 for (size_t i = 0; i < valuesCount; ++i) 85 values[i] = JSObjectMake(ctx, 0, 0); 86 pthread_mutex_unlock(&javaScriptThreadsMutex); 79 87 80 88 // Check for cancellation. 81 if (javaScriptThreadsShouldTerminate) { 82 javaScriptThreads()->remove(pthread_self()); 83 pthread_mutex_unlock(&javaScriptThreadsMutex); 84 return 0; 85 } 89 if (javaScriptThreadsShouldTerminate) 90 goto done; 86 91 87 92 // Respawn probabilistically. 88 93 if (random() % 5 == 0) { 94 pthread_mutex_lock(&javaScriptThreadsMutex); 89 95 pthread_t pthread; 90 96 pthread_create(&pthread, 0, &runJavaScriptThread, 0); 91 97 pthread_detach(pthread); 98 javaScriptThreads()->add(pthread); 99 pthread_mutex_unlock(&javaScriptThreadsMutex); 100 goto done; 101 } 102 } 92 103 93 javaScriptThreads()->remove(pthread_self()); 94 javaScriptThreads()->add(pthread); 95 96 pthread_mutex_unlock(&javaScriptThreadsMutex); 97 return 0; 98 } 99 100 pthread_mutex_unlock(&javaScriptThreadsMutex); 101 } 104 done: 105 pthread_mutex_lock(&javaScriptThreadsMutex); 106 JSStringRelease(scriptRef); 107 JSGarbageCollect(ctx); 108 JSGlobalContextRelease(ctx); 109 javaScriptThreads()->remove(pthread_self()); 110 pthread_mutex_unlock(&javaScriptThreadsMutex); 111 return 0; 102 112 } 103 113 104 114 void startJavaScriptThreads() 105 115 { 116 javaScriptThreadsGroup = JSContextGroupCreate(); 117 106 118 pthread_mutex_lock(&javaScriptThreadsMutex); 107 119 … … 122 134 javaScriptThreadsShouldTerminate = true; 123 135 124 ASSERT(javaScriptThreads()->size() == javaScriptThreadsCount);125 126 136 pthread_mutex_unlock(&javaScriptThreadsMutex); 127 137
Note: See TracChangeset
for help on using the changeset viewer.