- Revision
- 163964
- Author
- [email protected]
- Date
- 2014-02-12 10:40:35 -0800 (Wed, 12 Feb 2014)
Log Message
Adjust VM::stackLimit based on the size of the largest FTL stack produced
https://bugs.webkit.org/show_bug.cgi?id=128562
Reviewed by Mark Lam.
Added VM::m_largestFTLStackSize to track the largest stack size of an FTL compiled
function. Added VM::m_ftlStackLimit for FTL functions stack limit. Renamed
VM::updateStackLimitWithReservedZoneSize to VM::updateReservedZoneSize. Renamed
VM::setStackLimit to VM::updateStackLimit and changed it to do the updating of the
stack limits, including taking into account m_largestFTLStackSize.
* ftl/FTLJITFinalizer.cpp:
(JSC::FTL::JITFinalizer::finalizeFunction):
* runtime/ErrorHandlingScope.cpp:
(JSC::ErrorHandlingScope::ErrorHandlingScope):
(JSC::ErrorHandlingScope::~ErrorHandlingScope):
* runtime/JSLock.cpp:
(JSC::JSLock::lock):
(JSC::JSLock::unlock):
(JSC::JSLock::grabAllLocks):
* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::updateReservedZoneSize):
(JSC::VM::updateStackLimit):
(JSC::VM::updateFTLLargestStackSize):
* runtime/VM.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (163963 => 163964)
--- trunk/Source/_javascript_Core/ChangeLog 2014-02-12 18:17:47 UTC (rev 163963)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-02-12 18:40:35 UTC (rev 163964)
@@ -1,3 +1,32 @@
+2014-02-12 Michael Saboff <[email protected]>
+
+ Adjust VM::stackLimit based on the size of the largest FTL stack produced
+ https://bugs.webkit.org/show_bug.cgi?id=128562
+
+ Reviewed by Mark Lam.
+
+ Added VM::m_largestFTLStackSize to track the largest stack size of an FTL compiled
+ function. Added VM::m_ftlStackLimit for FTL functions stack limit. Renamed
+ VM::updateStackLimitWithReservedZoneSize to VM::updateReservedZoneSize. Renamed
+ VM::setStackLimit to VM::updateStackLimit and changed it to do the updating of the
+ stack limits, including taking into account m_largestFTLStackSize.
+
+ * ftl/FTLJITFinalizer.cpp:
+ (JSC::FTL::JITFinalizer::finalizeFunction):
+ * runtime/ErrorHandlingScope.cpp:
+ (JSC::ErrorHandlingScope::ErrorHandlingScope):
+ (JSC::ErrorHandlingScope::~ErrorHandlingScope):
+ * runtime/JSLock.cpp:
+ (JSC::JSLock::lock):
+ (JSC::JSLock::unlock):
+ (JSC::JSLock::grabAllLocks):
+ * runtime/VM.cpp:
+ (JSC::VM::VM):
+ (JSC::VM::updateReservedZoneSize):
+ (JSC::VM::updateStackLimit):
+ (JSC::VM::updateFTLLargestStackSize):
+ * runtime/VM.h:
+
2014-02-11 Oliver Hunt <[email protected]>
Make it possible to implement JS builtins in JS
Modified: trunk/Source/_javascript_Core/ftl/FTLJITFinalizer.cpp (163963 => 163964)
--- trunk/Source/_javascript_Core/ftl/FTLJITFinalizer.cpp 2014-02-12 18:17:47 UTC (rev 163963)
+++ trunk/Source/_javascript_Core/ftl/FTLJITFinalizer.cpp 2014-02-12 18:40:35 UTC (rev 163964)
@@ -136,7 +136,9 @@
("FTL entrypoint thunk for %s with LLVM generated code at %p", toCString(CodeBlockWithJITType(m_plan.codeBlock.get(), JITCode::FTLJIT)).data(), function)));
m_plan.codeBlock->setJITCode(jitCode);
-
+
+ m_plan.vm.updateFTLLargestStackSize(jitCode->stackmaps.stackSize());
+
if (m_plan.compilation)
m_plan.vm.m_perBytecodeProfiler->addCompilation(m_plan.compilation);
Modified: trunk/Source/_javascript_Core/runtime/ErrorHandlingScope.cpp (163963 => 163964)
--- trunk/Source/_javascript_Core/runtime/ErrorHandlingScope.cpp 2014-02-12 18:17:47 UTC (rev 163963)
+++ trunk/Source/_javascript_Core/runtime/ErrorHandlingScope.cpp 2014-02-12 18:40:35 UTC (rev 163964)
@@ -38,7 +38,7 @@
if (!m_vm.stackPointerAtVMEntry)
m_vm.stackPointerAtVMEntry = this;
size_t newReservedZoneSize = Options::errorModeReservedZoneSize();
- m_savedReservedZoneSize = m_vm.updateStackLimitWithReservedZoneSize(newReservedZoneSize);
+ m_savedReservedZoneSize = m_vm.updateReservedZoneSize(newReservedZoneSize);
#if ENABLE(LLINT_C_LOOP)
m_vm.interpreter->stack().setReservedZoneSize(newReservedZoneSize);
#endif
@@ -48,7 +48,7 @@
{
if (m_vm.stackPointerAtVMEntry == this)
m_vm.stackPointerAtVMEntry = nullptr;
- m_vm.updateStackLimitWithReservedZoneSize(m_savedReservedZoneSize);
+ m_vm.updateReservedZoneSize(m_savedReservedZoneSize);
#if ENABLE(LLINT_C_LOOP)
m_vm.interpreter->stack().setReservedZoneSize(m_savedReservedZoneSize);
#endif
Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (163963 => 163964)
--- trunk/Source/_javascript_Core/runtime/JSLock.cpp 2014-02-12 18:17:47 UTC (rev 163963)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp 2014-02-12 18:40:35 UTC (rev 163964)
@@ -126,7 +126,7 @@
if (!m_vm->stackPointerAtVMEntry) {
void* p = &p;
m_vm->stackPointerAtVMEntry = p; // A proxy for the current stack pointer.
- threadData.setSavedReservedZoneSize(m_vm->updateStackLimitWithReservedZoneSize(Options::reservedZoneSize()));
+ threadData.setSavedReservedZoneSize(m_vm->updateReservedZoneSize(Options::reservedZoneSize()));
}
m_vm->setLastStackTop(threadData.savedLastStackTop());
@@ -147,7 +147,7 @@
if (!m_lockCount) {
if (m_vm) {
m_vm->stackPointerAtVMEntry = nullptr;
- m_vm->updateStackLimitWithReservedZoneSize(wtfThreadData().savedReservedZoneSize());
+ m_vm->updateReservedZoneSize(wtfThreadData().savedReservedZoneSize());
}
setOwnerThread(0);
m_lock.unlock();
@@ -218,7 +218,7 @@
WTFThreadData& threadData = wtfThreadData();
m_vm->stackPointerAtVMEntry = threadData.savedStackPointerAtVMEntry();
m_vm->setLastStackTop(threadData.savedLastStackTop());
- m_vm->updateStackLimitWithReservedZoneSize(threadData.savedReservedZoneSize());
+ m_vm->updateReservedZoneSize(threadData.savedReservedZoneSize());
}
JSLock::DropAllLocks::DropAllLocks(ExecState* exec)
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (163963 => 163964)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2014-02-12 18:17:47 UTC (rev 163963)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2014-02-12 18:40:35 UTC (rev 163964)
@@ -227,6 +227,10 @@
#if ENABLE(LLINT_C_LOOP)
, m_jsStackLimit(0)
#endif
+#if ENABLE(FTL_JIT)
+ , m_ftlStackLimit(0)
+ , m_largestFTLStackSize(0)
+#endif
, m_inDefineOwnProperty(false)
, m_codeCache(CodeCache::create())
, m_enabledProfiler(nullptr)
@@ -234,7 +238,7 @@
{
interpreter = new Interpreter(*this);
StackBounds stack = wtfThreadData().stack();
- updateStackLimitWithReservedZoneSize(Options::reservedZoneSize());
+ updateReservedZoneSize(Options::reservedZoneSize());
#if ENABLE(LLINT_C_LOOP)
interpreter->stack().setReservedZoneSize(Options::reservedZoneSize());
#endif
@@ -728,23 +732,48 @@
m_exceptionStack = RefCountedArray<StackFrame>();
}
-size_t VM::updateStackLimitWithReservedZoneSize(size_t reservedZoneSize)
+size_t VM::updateReservedZoneSize(size_t reservedZoneSize)
{
size_t oldReservedZoneSize = m_reservedZoneSize;
m_reservedZoneSize = reservedZoneSize;
- void* stackLimit;
+ updateStackLimit();
+
+ return oldReservedZoneSize;
+}
+
+inline void VM::updateStackLimit()
+{
if (stackPointerAtVMEntry) {
ASSERT(wtfThreadData().stack().isGrowingDownward());
char* startOfStack = reinterpret_cast<char*>(stackPointerAtVMEntry);
- stackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), reservedZoneSize);
- } else
- stackLimit = wtfThreadData().stack().recursionLimit(reservedZoneSize);
+#if ENABLE(FTL_JIT)
+ m_stackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), m_reservedZoneSize + m_largestFTLStackSize);
+ m_ftlStackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), m_reservedZoneSize + 2 * m_largestFTLStackSize);
+#else
+ m_stackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), m_reservedZoneSize);
+#endif
+ } else {
+#if ENABLE(FTL_JIT)
+ m_stackLimit = wtfThreadData().stack().recursionLimit(m_reservedZoneSize + m_largestFTLStackSize);
+ m_ftlStackLimit = wtfThreadData().stack().recursionLimit(m_reservedZoneSize + 2 * m_largestFTLStackSize);
+#else
+ m_stackLimit = wtfThreadData().stack().recursionLimit(m_reservedZoneSize);
+#endif
+ }
- setStackLimit(stackLimit);
- return oldReservedZoneSize;
}
+#if ENABLE(FTL_JIT)
+void VM::updateFTLLargestStackSize(size_t stackSize)
+{
+ if (stackSize > m_largestFTLStackSize) {
+ m_largestFTLStackSize = stackSize;
+ updateStackLimit();
+ }
+}
+#endif
+
void releaseExecutableMemory(VM& vm)
{
vm.releaseExecutableMemory();
Modified: trunk/Source/_javascript_Core/runtime/VM.h (163963 => 163964)
--- trunk/Source/_javascript_Core/runtime/VM.h 2014-02-12 18:17:47 UTC (rev 163963)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2014-02-12 18:40:35 UTC (rev 163964)
@@ -380,8 +380,12 @@
JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
size_t reservedZoneSize() const { return m_reservedZoneSize; }
- size_t updateStackLimitWithReservedZoneSize(size_t reservedZoneSize);
+ size_t updateReservedZoneSize(size_t reservedZoneSize);
+#if ENABLE(FTL_JIT)
+ void updateFTLLargestStackSize(size_t);
+#endif
+
void** addressOfJSStackLimit() { return &m_jsStackLimit; }
#if ENABLE(LLINT_C_LOOP)
void* jsStackLimit() { return m_jsStackLimit; }
@@ -511,7 +515,7 @@
static VM*& sharedInstanceInternal();
void createNativeThunk();
- void setStackLimit(void* limit) { m_stackLimit = limit; }
+ void updateStackLimit();
#if ENABLE(ASSEMBLER)
bool m_canUseAssembler;
@@ -536,7 +540,11 @@
void* m_stackLimit;
void* m_jsStackLimit;
};
+#if ENABLE(FTL_JIT)
+ void* m_ftlStackLimit;
+ size_t m_largestFTLStackSize;
#endif
+#endif
void* m_lastStackTop;
JSValue m_exception;
bool m_inDefineOwnProperty;