Title: [172009] trunk/Source/_javascript_Core
- Revision
- 172009
- Author
- [email protected]
- Date
- 2014-08-04 15:04:39 -0700 (Mon, 04 Aug 2014)
Log Message
Create a more generic way for VMEntryScope to notify those interested that it will be destroyed
https://bugs.webkit.org/show_bug.cgi?id=135358
Patch by Saam Barati <[email protected]> on 2014-08-04
Reviewed by Geoffrey Garen.
When VMEntryScope is destroyed, and it has a flag set indicating that the
Debugger needs to recompile all functions, it calls Debugger::recompileAllJSFunctions.
This flag is only used by Debugger to have VMEntryScope notify it when the
Debugger is safe to recompile all functions. This patch will substitute this
Debugger-specific recompilation flag with a list of callbacks that are notified
when the outermost VMEntryScope dies. This creates a general purpose interface
for being notified when the VM stops executing code via the event of the outermost
VMEntryScope dying.
* debugger/Debugger.cpp:
(JSC::Debugger::recompileAllJSFunctions):
* runtime/VMEntryScope.cpp:
(JSC::VMEntryScope::VMEntryScope):
(JSC::VMEntryScope::addEntryScopeDidPopListener):
(JSC::VMEntryScope::~VMEntryScope):
* runtime/VMEntryScope.h:
(JSC::VMEntryScope::setRecompilationNeeded): Deleted.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (172008 => 172009)
--- trunk/Source/_javascript_Core/ChangeLog 2014-08-04 22:01:04 UTC (rev 172008)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-08-04 22:04:39 UTC (rev 172009)
@@ -1,3 +1,28 @@
+2014-08-04 Saam Barati <[email protected]>
+
+ Create a more generic way for VMEntryScope to notify those interested that it will be destroyed
+ https://bugs.webkit.org/show_bug.cgi?id=135358
+
+ Reviewed by Geoffrey Garen.
+
+ When VMEntryScope is destroyed, and it has a flag set indicating that the
+ Debugger needs to recompile all functions, it calls Debugger::recompileAllJSFunctions.
+ This flag is only used by Debugger to have VMEntryScope notify it when the
+ Debugger is safe to recompile all functions. This patch will substitute this
+ Debugger-specific recompilation flag with a list of callbacks that are notified
+ when the outermost VMEntryScope dies. This creates a general purpose interface
+ for being notified when the VM stops executing code via the event of the outermost
+ VMEntryScope dying.
+
+ * debugger/Debugger.cpp:
+ (JSC::Debugger::recompileAllJSFunctions):
+ * runtime/VMEntryScope.cpp:
+ (JSC::VMEntryScope::VMEntryScope):
+ (JSC::VMEntryScope::addEntryScopeDidPopListener):
+ (JSC::VMEntryScope::~VMEntryScope):
+ * runtime/VMEntryScope.h:
+ (JSC::VMEntryScope::setRecompilationNeeded): Deleted.
+
2014-08-01 Carlos Alberto Lopez Perez <[email protected]>
REGRESSION(r171942): [CMAKE] [GTK] build broken (clean build).
Modified: trunk/Source/_javascript_Core/debugger/Debugger.cpp (172008 => 172009)
--- trunk/Source/_javascript_Core/debugger/Debugger.cpp 2014-08-04 22:01:04 UTC (rev 172008)
+++ trunk/Source/_javascript_Core/debugger/Debugger.cpp 2014-08-04 22:04:39 UTC (rev 172009)
@@ -335,7 +335,14 @@
// If _javascript_ is running, it's not safe to recompile, since we'll end
// up throwing away code that is live on the stack.
if (vm->entryScope) {
- vm->entryScope->setRecompilationNeeded(true);
+ auto listener = [] (VM* vm, JSGlobalObject* globalObject)
+ {
+ Debugger* debugger = globalObject->debugger();
+ if (debugger)
+ debugger->recompileAllJSFunctions(vm);
+ };
+
+ vm->entryScope->addEntryScopeDidPopListener(this, listener);
return;
}
Modified: trunk/Source/_javascript_Core/runtime/VMEntryScope.cpp (172008 => 172009)
--- trunk/Source/_javascript_Core/runtime/VMEntryScope.cpp 2014-08-04 22:01:04 UTC (rev 172008)
+++ trunk/Source/_javascript_Core/runtime/VMEntryScope.cpp 2014-08-04 22:04:39 UTC (rev 172009)
@@ -36,7 +36,6 @@
VMEntryScope::VMEntryScope(VM& vm, JSGlobalObject* globalObject)
: m_vm(vm)
, m_globalObject(globalObject)
- , m_recompilationNeeded(false)
{
ASSERT(wtfThreadData().stack().isGrowingDownward());
if (!vm.entryScope) {
@@ -55,6 +54,11 @@
vm.clearExceptionStack();
}
+void VMEntryScope::addEntryScopeDidPopListener(void* key, EntryScopeDidPopListener listener)
+{
+ m_allEntryScopeDidPopListeners.set(key, listener);
+}
+
VMEntryScope::~VMEntryScope()
{
if (m_vm.entryScope != this)
@@ -62,9 +66,11 @@
m_vm.entryScope = nullptr;
- if (m_recompilationNeeded) {
- if (Debugger* debugger = m_globalObject->debugger())
- debugger->recompileAllJSFunctions(&m_vm);
+ auto iter = m_allEntryScopeDidPopListeners.begin();
+ auto end = m_allEntryScopeDidPopListeners.end();
+ for ( ; iter != end; ++iter) {
+ EntryScopeDidPopListener listener = iter->value;
+ listener(&m_vm, m_globalObject);
}
}
Modified: trunk/Source/_javascript_Core/runtime/VMEntryScope.h (172008 => 172009)
--- trunk/Source/_javascript_Core/runtime/VMEntryScope.h 2014-08-04 22:01:04 UTC (rev 172008)
+++ trunk/Source/_javascript_Core/runtime/VMEntryScope.h 2014-08-04 22:04:39 UTC (rev 172009)
@@ -27,6 +27,7 @@
#define VMEntryScope_h
#include "Interpreter.h"
+#include <wtf/HashMap.h>
#include <wtf/StackBounds.h>
#include <wtf/StackStats.h>
@@ -42,12 +43,13 @@
JSGlobalObject* globalObject() const { return m_globalObject; }
- void setRecompilationNeeded(bool recompileNeeded) { m_recompilationNeeded = recompileNeeded; }
+ typedef std::function<void (VM*, JSGlobalObject*)> EntryScopeDidPopListener;
+ void addEntryScopeDidPopListener(void*, EntryScopeDidPopListener);
private:
VM& m_vm;
JSGlobalObject* m_globalObject;
- bool m_recompilationNeeded;
+ HashMap<void*, EntryScopeDidPopListener> m_allEntryScopeDidPopListeners;
};
} // namespace JSC
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes