Title: [188344] trunk/Source/_javascript_Core
Revision
188344
Author
[email protected]
Date
2015-08-12 12:16:49 -0700 (Wed, 12 Aug 2015)

Log Message

Roll out r188339, which broke the build.

Unreviewed.

* jit/ExecutableAllocator.h:
* jsc.cpp:
(GlobalObject::finishCreation):
(functionReleaseExecutableMemory):
* runtime/VM.cpp:
(JSC::StackPreservingRecompiler::visit):
(JSC::StackPreservingRecompiler::operator()):
(JSC::VM::releaseExecutableMemory):
(JSC::releaseExecutableMemory):
* runtime/VM.h:
* runtime/Watchdog.cpp:
(JSC::Watchdog::setTimeLimit):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (188343 => 188344)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-12 19:03:12 UTC (rev 188343)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-12 19:16:49 UTC (rev 188344)
@@ -1,3 +1,22 @@
+2015-08-12  Jon Honeycutt  <[email protected]>
+
+        Roll out r188339, which broke the build.
+
+        Unreviewed.
+
+        * jit/ExecutableAllocator.h:
+        * jsc.cpp:
+        (GlobalObject::finishCreation):
+        (functionReleaseExecutableMemory):
+        * runtime/VM.cpp:
+        (JSC::StackPreservingRecompiler::visit):
+        (JSC::StackPreservingRecompiler::operator()):
+        (JSC::VM::releaseExecutableMemory):
+        (JSC::releaseExecutableMemory):
+        * runtime/VM.h:
+        * runtime/Watchdog.cpp:
+        (JSC::Watchdog::setTimeLimit):
+
 2015-08-12  Alex Christensen  <[email protected]>
 
         Fix Debug CMake builds on Windows

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.h (188343 => 188344)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.h	2015-08-12 19:03:12 UTC (rev 188343)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.h	2015-08-12 19:16:49 UTC (rev 188344)
@@ -67,6 +67,7 @@
 namespace JSC {
 
 class VM;
+void releaseExecutableMemory(VM&);
 
 static const unsigned jitAllocationGranule = 32;
 

Modified: trunk/Source/_javascript_Core/jsc.cpp (188343 => 188344)


--- trunk/Source/_javascript_Core/jsc.cpp	2015-08-12 19:03:12 UTC (rev 188343)
+++ trunk/Source/_javascript_Core/jsc.cpp	2015-08-12 19:16:49 UTC (rev 188344)
@@ -463,6 +463,7 @@
 static EncodedJSValue JSC_HOST_CALL functionDeleteAllCompiledCode(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionAddressOf(ExecState*);
 #ifndef NDEBUG
+static EncodedJSValue JSC_HOST_CALL functionReleaseExecutableMemory(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionDumpCallFrame(ExecState*);
 #endif
 static EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*);
@@ -611,6 +612,7 @@
         addFunction(vm, "addressOf", functionAddressOf, 1);
 #ifndef NDEBUG
         addFunction(vm, "dumpCallFrame", functionDumpCallFrame, 0);
+        addFunction(vm, "releaseExecutableMemory", functionReleaseExecutableMemory, 0);
 #endif
         addFunction(vm, "version", functionVersion, 1);
         addFunction(vm, "run", functionRun, 1);
@@ -907,6 +909,16 @@
     return returnValue;
 }
 
+
+#ifndef NDEBUG
+EncodedJSValue JSC_HOST_CALL functionReleaseExecutableMemory(ExecState* exec)
+{
+    JSLockHolder lock(exec);
+    exec->vm().releaseExecutableMemory();
+    return JSValue::encode(jsUndefined());
+}
+#endif
+
 EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*)
 {
     // We need this function for compatibility with the Mozilla JS tests but for now

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (188343 => 188344)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2015-08-12 19:03:12 UTC (rev 188343)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2015-08-12 19:16:49 UTC (rev 188344)
@@ -510,6 +510,58 @@
     sourceProviderCacheMap.clear();
 }
 
+struct StackPreservingRecompiler : public MarkedBlock::VoidFunctor {
+    HashSet<FunctionExecutable*> currentlyExecutingFunctions;
+    inline void visit(JSCell* cell)
+    {
+        if (!cell->inherits(FunctionExecutable::info()))
+            return;
+        FunctionExecutable* executable = jsCast<FunctionExecutable*>(cell);
+        if (currentlyExecutingFunctions.contains(executable))
+            return;
+        executable->clearCode();
+    }
+    IterationStatus operator()(JSCell* cell)
+    {
+        visit(cell);
+        return IterationStatus::Continue;
+    }
+};
+
+void VM::releaseExecutableMemory()
+{
+    prepareToDiscardCode();
+    
+    if (entryScope) {
+        StackPreservingRecompiler recompiler;
+        HeapIterationScope iterationScope(heap);
+        HashSet<JSCell*> roots;
+        heap.getConservativeRegisterRoots(roots);
+        HashSet<JSCell*>::iterator end = roots.end();
+        for (HashSet<JSCell*>::iterator ptr = roots.begin(); ptr != end; ++ptr) {
+            ScriptExecutable* executable = 0;
+            JSCell* cell = *ptr;
+            if (cell->inherits(ScriptExecutable::info()))
+                executable = static_cast<ScriptExecutable*>(*ptr);
+            else if (cell->inherits(JSFunction::info())) {
+                JSFunction* function = jsCast<JSFunction*>(*ptr);
+                if (function->isHostFunction())
+                    continue;
+                executable = function->jsExecutable();
+            } else
+                continue;
+            ASSERT(executable->inherits(ScriptExecutable::info()));
+            executable->unlinkCalls();
+            if (executable->inherits(FunctionExecutable::info()))
+                recompiler.currentlyExecutingFunctions.add(static_cast<FunctionExecutable*>(executable));
+                
+        }
+        heap.objectSpace().forEachLiveCell<StackPreservingRecompiler>(iterationScope, recompiler);
+    }
+    m_regExpCache->invalidateCode();
+    heap.collectAllGarbage();
+}
+
 void VM::throwException(ExecState* exec, Exception* exception)
 {
     if (Options::breakOnThrow()) {
@@ -617,6 +669,11 @@
 }
 #endif
 
+void releaseExecutableMemory(VM& vm)
+{
+    vm.releaseExecutableMemory();
+}
+
 #if ENABLE(DFG_JIT)
 void VM::gatherConservativeRoots(ConservativeRoots& conservativeRoots)
 {

Modified: trunk/Source/_javascript_Core/runtime/VM.h (188343 => 188344)


--- trunk/Source/_javascript_Core/runtime/VM.h	2015-08-12 19:03:12 UTC (rev 188343)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2015-08-12 19:16:49 UTC (rev 188344)
@@ -514,6 +514,7 @@
     JS_EXPORT_PRIVATE void dumpRegExpTrace();
 
     bool isCollectorBusy() { return heap.isBusy(); }
+    JS_EXPORT_PRIVATE void releaseExecutableMemory();
 
 #if ENABLE(GC_VALIDATION)
     bool isInitializingObject() const; 

Modified: trunk/Source/_javascript_Core/runtime/Watchdog.cpp (188343 => 188344)


--- trunk/Source/_javascript_Core/runtime/Watchdog.cpp	2015-08-12 19:03:12 UTC (rev 188343)
+++ trunk/Source/_javascript_Core/runtime/Watchdog.cpp	2015-08-12 19:16:49 UTC (rev 188344)
@@ -84,7 +84,7 @@
     if (!hadTimeLimit) {
         // And if we've previously compiled any functions, we need to revert
         // them because they don't have the needed polling checks yet.
-        vm.discardAllCode();
+        vm.releaseExecutableMemory();
     }
 
     if (m_hasEnteredVM && hasTimeLimit())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to