Diff
Modified: trunk/Source/_javascript_Core/API/tests/testapi.mm (180590 => 180591)
--- trunk/Source/_javascript_Core/API/tests/testapi.mm 2015-02-24 23:33:08 UTC (rev 180590)
+++ trunk/Source/_javascript_Core/API/tests/testapi.mm 2015-02-25 00:03:42 UTC (rev 180591)
@@ -473,7 +473,7 @@
return containsClass;
}
-static void* useVMFromOtherThread(void* contextPtr)
+static void* threadMain(void* contextPtr)
{
JSContext *context = (__bridge JSContext*)contextPtr;
@@ -483,32 +483,6 @@
pthread_exit(nullptr);
}
-struct ThreadArgs {
- JSContext* context;
- volatile bool* mainThreadIsReadyToJoin;
- volatile bool* otherThreadIsDoneWithJSWork;
-};
-
-static void* useVMFromOtherThreadAndOutliveVM(void* data)
-{
- ThreadArgs* args = reinterpret_cast<ThreadArgs*>(data);
- volatile bool& mainThreadIsReadyToJoin = *args->mainThreadIsReadyToJoin;
- volatile bool& otherThreadIsDoneWithJSWork = *args->otherThreadIsDoneWithJSWork;
-
- @autoreleasepool {
- JSContext *context = args->context;
-
- // Do something to enter the VM.
- TestObject *testObject = [TestObject testObject];
- context[@"testObject"] = testObject;
- }
- otherThreadIsDoneWithJSWork = true;
-
- while (!mainThreadIsReadyToJoin)
- usleep(10000);
- pthread_exit(nullptr);
-}
-
void testObjectiveCAPI()
{
NSLog(@"Testing Objective-C API");
@@ -1402,33 +1376,13 @@
JSContext *context = [[JSContext alloc] init];
pthread_t threadID;
- pthread_create(&threadID, NULL, &useVMFromOtherThread, (__bridge void*)context);
+ pthread_create(&threadID, NULL, &threadMain, (__bridge void*)context);
pthread_join(threadID, nullptr);
JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
checkResult(@"Did not crash after entering the VM from another thread", true);
}
-
- @autoreleasepool {
- pthread_t threadID;
- volatile bool mainThreadIsReadyToJoin = false;
- volatile bool otherThreadIsDoneWithJSWork = false;
- @autoreleasepool {
- JSContext *context = [[JSContext alloc] init];
- ThreadArgs args = { context, &mainThreadIsReadyToJoin, &otherThreadIsDoneWithJSWork };
-
- pthread_create(&threadID, NULL, &useVMFromOtherThreadAndOutliveVM, &args);
- JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
-
- while (!otherThreadIsDoneWithJSWork)
- usleep(10000);
- }
-
- mainThreadIsReadyToJoin = true;
- pthread_join(threadID, nullptr);
- checkResult(@"Did not crash if the VM is destructed before another thread using the VM ends", true);
- }
-
+
currentThisInsideBlockGetterTest();
runDateTests();
runJSExportTests();
Modified: trunk/Source/_javascript_Core/ChangeLog (180590 => 180591)
--- trunk/Source/_javascript_Core/ChangeLog 2015-02-24 23:33:08 UTC (rev 180590)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-02-25 00:03:42 UTC (rev 180591)
@@ -1,3 +1,29 @@
+2015-02-24 Mark Lam <mark....@apple.com>
+
+ Rolling out r179753. The fix was invalid.
+ <https://webkit.org/b/141990>
+
+ Not reviewed.
+
+ * API/tests/testapi.mm:
+ (threadMain):
+ (useVMFromOtherThread): Deleted.
+ (useVMFromOtherThreadAndOutliveVM): Deleted.
+ * heap/Heap.cpp:
+ (JSC::Heap::Heap):
+ (JSC::Heap::~Heap):
+ (JSC::Heap::gatherStackRoots):
+ * heap/Heap.h:
+ (JSC::Heap::machineThreads):
+ * heap/MachineStackMarker.cpp:
+ (JSC::MachineThreads::Thread::Thread):
+ (JSC::MachineThreads::MachineThreads):
+ (JSC::MachineThreads::~MachineThreads):
+ (JSC::MachineThreads::addCurrentThread):
+ (JSC::MachineThreads::removeThread):
+ (JSC::MachineThreads::removeCurrentThread):
+ * heap/MachineStackMarker.h:
+
2015-02-24 Yusuke Suzuki <utatane....@gmail.com>
Constructor returning null should construct an object instead of null
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (180590 => 180591)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2015-02-24 23:33:08 UTC (rev 180590)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2015-02-25 00:03:42 UTC (rev 180591)
@@ -311,6 +311,7 @@
, m_objectSpace(this)
, m_storageSpace(this)
, m_extraMemoryUsage(0)
+ , m_machineThreads(this)
, m_sharedData(vm)
, m_slotVisitor(m_sharedData)
, m_copyVisitor(m_sharedData)
@@ -339,7 +340,6 @@
, m_delayedReleaseRecursionCount(0)
#endif
{
- m_machineThreads = adoptRef(new MachineThreads(this));
m_storageSpace.init();
if (Options::verifyHeap())
m_verifier = std::make_unique<HeapVerifier>(this, Options::numberOfGCCyclesToRecordForVerification());
@@ -347,9 +347,6 @@
Heap::~Heap()
{
- // We need to remove the main thread explicitly here because the main thread
- // may not terminate for a while though the Heap (and VM) is being shut down.
- m_machineThreads->removeCurrentThread();
}
bool Heap::isPagedOut(double deadline)
@@ -590,7 +587,7 @@
{
GCPHASE(GatherStackRoots);
m_jitStubRoutines.clearMarks();
- m_machineThreads->gatherConservativeRoots(roots, m_jitStubRoutines, m_codeBlocks, dummy, registers);
+ m_machineThreads.gatherConservativeRoots(roots, m_jitStubRoutines, m_codeBlocks, dummy, registers);
}
void Heap::gatherJSStackRoots(ConservativeRoots& roots)
Modified: trunk/Source/_javascript_Core/heap/Heap.h (180590 => 180591)
--- trunk/Source/_javascript_Core/heap/Heap.h 2015-02-24 23:33:08 UTC (rev 180590)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2015-02-25 00:03:42 UTC (rev 180591)
@@ -119,7 +119,7 @@
VM* vm() const { return m_vm; }
MarkedSpace& objectSpace() { return m_objectSpace; }
- MachineThreads& machineThreads() { return *m_machineThreads; }
+ MachineThreads& machineThreads() { return m_machineThreads; }
const SlotVisitor& slotVisitor() const { return m_slotVisitor; }
@@ -355,7 +355,7 @@
Vector<Vector<ValueStringPair, 0, UnsafeVectorOverflow>*> m_tempSortingVectors;
std::unique_ptr<HashSet<MarkedArgumentBuffer*>> m_markListSet;
- RefPtr<MachineThreads> m_machineThreads;
+ MachineThreads m_machineThreads;
GCThreadSharedData m_sharedData;
SlotVisitor m_slotVisitor;
Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp (180590 => 180591)
--- trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp 2015-02-24 23:33:08 UTC (rev 180590)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp 2015-02-25 00:03:42 UTC (rev 180591)
@@ -91,10 +91,9 @@
class MachineThreads::Thread {
WTF_MAKE_FAST_ALLOCATED;
public:
- Thread(PassRefPtr<MachineThreads> machineThreads, const PlatformThread& platThread, void* base)
+ Thread(const PlatformThread& platThread, void* base)
: platformThread(platThread)
, stackBase(base)
- , m_machineThreads(machineThreads)
{
#if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) && defined(SA_RESTART)
// if we have SA_RESTART, enable SIGUSR2 debugging mechanism
@@ -114,7 +113,6 @@
Thread* next;
PlatformThread platformThread;
void* stackBase;
- RefPtr<MachineThreads> m_machineThreads;
};
MachineThreads::MachineThreads(Heap* heap)
@@ -122,7 +120,6 @@
, m_threadSpecific(0)
#if !ASSERT_DISABLED
, m_heap(heap)
- , m_magicNumber(0x1234567890abcdef)
#endif
{
UNUSED_PARAM(heap);
@@ -139,9 +136,6 @@
delete t;
t = next;
}
-#if !ASSERT_DISABLED
- m_magicNumber = 0xbaddbeefdeadbeef;
-#endif
}
static inline PlatformThread getCurrentPlatformThread()
@@ -176,7 +170,7 @@
}
threadSpecificSet(m_threadSpecific, this);
- Thread* thread = new Thread(this, getCurrentPlatformThread(), wtfThreadData().stack().origin());
+ Thread* thread = new Thread(getCurrentPlatformThread(), wtfThreadData().stack().origin());
MutexLocker lock(m_registeredThreadsMutex);
@@ -186,7 +180,6 @@
void MachineThreads::removeThread(void* p)
{
- ASSERT(static_cast<MachineThreads*>(p)->m_magicNumber == 0x1234567890abcdef);
static_cast<MachineThreads*>(p)->removeCurrentThread();
}
@@ -194,21 +187,6 @@
{
PlatformThread currentPlatformThread = getCurrentPlatformThread();
- // This thread could be the last entity that holds a RefPtr to the
- // MachineThreads registry. We don't want the registry to be deleted while
- // we're deleting the the Thread entry, because:
- //
- // 1. ~MachineThread() will attempt to lock its m_registeredThreadsMutex
- // and we already hold it here. m_registeredThreadsMutex is not
- // re-entrant.
- // 2. The MutexLocker will unlock m_registeredThreadsMutex at the end of
- // this function. We can't let it be destructed until before then.
- //
- // Using this RefPtr here will defer destructing the registry till after
- // MutexLocker releases its m_registeredThreadsMutex.
- RefPtr<MachineThreads> retainMachineThreadsRegistryUntilDoneRemovingThread = this;
-
- ASSERT(m_magicNumber == 0x1234567890abcdef);
MutexLocker lock(m_registeredThreadsMutex);
if (equalThread(currentPlatformThread, m_registeredThreads->platformThread)) {
Thread* t = m_registeredThreads;
Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.h (180590 => 180591)
--- trunk/Source/_javascript_Core/heap/MachineStackMarker.h 2015-02-24 23:33:08 UTC (rev 180590)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.h 2015-02-25 00:03:42 UTC (rev 180591)
@@ -24,7 +24,6 @@
#include <setjmp.h>
#include <wtf/Noncopyable.h>
-#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/ThreadSpecific.h>
#include <wtf/ThreadingPrimitives.h>
@@ -35,7 +34,7 @@
class Heap;
class JITStubRoutineSet;
- class MachineThreads : public ThreadSafeRefCounted<MachineThreads> {
+ class MachineThreads {
WTF_MAKE_NONCOPYABLE(MachineThreads);
public:
typedef jmp_buf RegisterState;
@@ -47,8 +46,6 @@
JS_EXPORT_PRIVATE void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads.
- void removeCurrentThread();
-
private:
class Thread;
@@ -58,13 +55,13 @@
bool tryCopyOtherThreadStacks(MutexLocker&, void*, size_t capacity, size_t*);
static void removeThread(void*);
+ void removeCurrentThread();
Mutex m_registeredThreadsMutex;
Thread* m_registeredThreads;
WTF::ThreadSpecificKey m_threadSpecific;
#if !ASSERT_DISABLED
Heap* m_heap;
- uint64_t m_magicNumber; // Only used for detecting use after free.
#endif
};