summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/disassembler/Disassembler.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/disassembler/Disassembler.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/disassembler/Disassembler.cpp')
-rw-r--r--Source/JavaScriptCore/disassembler/Disassembler.cpp117
1 files changed, 6 insertions, 111 deletions
diff --git a/Source/JavaScriptCore/disassembler/Disassembler.cpp b/Source/JavaScriptCore/disassembler/Disassembler.cpp
index 788a6c362..a72e22a9e 100644
--- a/Source/JavaScriptCore/disassembler/Disassembler.cpp
+++ b/Source/JavaScriptCore/disassembler/Disassembler.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,126 +26,21 @@
#include "config.h"
#include "Disassembler.h"
+#if ENABLE(DISASSEMBLER)
+
#include "MacroAssemblerCodeRef.h"
-#include <wtf/Condition.h>
#include <wtf/DataLog.h>
-#include <wtf/Deque.h>
-#include <wtf/Lock.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/StringPrintStream.h>
-#include <wtf/Threading.h>
namespace JSC {
-void disassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
+void disassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out, InstructionSubsetHint subsetHint)
{
- if (tryToDisassemble(codePtr, size, prefix, out))
+ if (tryToDisassemble(codePtr, size, prefix, out, subsetHint))
return;
out.printf("%sdisassembly not available for range %p...%p\n", prefix, codePtr.executableAddress(), static_cast<char*>(codePtr.executableAddress()) + size);
}
-namespace {
-
-// This is really a struct, except that it should be a class because that's what the WTF_* macros
-// expect.
-class DisassemblyTask {
- WTF_MAKE_NONCOPYABLE(DisassemblyTask);
- WTF_MAKE_FAST_ALLOCATED;
-public:
- DisassemblyTask()
- {
- }
-
- ~DisassemblyTask()
- {
- if (header)
- free(header); // free() because it would have been copied by strdup.
- }
-
- char* header { nullptr };
- MacroAssemblerCodeRef codeRef;
- size_t size { 0 };
- const char* prefix { nullptr };
-};
-
-class AsynchronousDisassembler {
-public:
- AsynchronousDisassembler()
- {
- createThread("Asynchronous Disassembler", [&] () { run(); });
- }
-
- void enqueue(std::unique_ptr<DisassemblyTask> task)
- {
- LockHolder locker(m_lock);
- m_queue.append(WTFMove(task));
- m_condition.notifyAll();
- }
-
- void waitUntilEmpty()
- {
- LockHolder locker(m_lock);
- while (!m_queue.isEmpty() || m_working)
- m_condition.wait(m_lock);
- }
-
-private:
- NO_RETURN void run()
- {
- for (;;) {
- std::unique_ptr<DisassemblyTask> task;
- {
- LockHolder locker(m_lock);
- m_working = false;
- m_condition.notifyAll();
- while (m_queue.isEmpty())
- m_condition.wait(m_lock);
- task = m_queue.takeFirst();
- m_working = true;
- }
-
- dataLog(task->header);
- disassemble(task->codeRef.code(), task->size, task->prefix, WTF::dataFile());
- }
- }
-
- Lock m_lock;
- Condition m_condition;
- Deque<std::unique_ptr<DisassemblyTask>> m_queue;
- bool m_working { false };
-};
-
-bool hadAnyAsynchronousDisassembly = false;
-
-AsynchronousDisassembler& asynchronousDisassembler()
-{
- static NeverDestroyed<AsynchronousDisassembler> disassembler;
- hadAnyAsynchronousDisassembly = true;
- return disassembler.get();
-}
-
-} // anonymous namespace
-
-void disassembleAsynchronously(
- const CString& header, const MacroAssemblerCodeRef& codeRef, size_t size, const char* prefix)
-{
- std::unique_ptr<DisassemblyTask> task = std::make_unique<DisassemblyTask>();
- task->header = strdup(header.data()); // Yuck! We need this because CString does racy refcounting.
- task->codeRef = codeRef;
- task->size = size;
- task->prefix = prefix;
-
- asynchronousDisassembler().enqueue(WTFMove(task));
-}
-
-void waitForAsynchronousDisassembly()
-{
- if (!hadAnyAsynchronousDisassembly)
- return;
-
- asynchronousDisassembler().waitUntilEmpty();
-}
-
} // namespace JSC
+#endif // ENABLE(DISASSEMBLER)