diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/runtime/VMEntryScope.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/runtime/VMEntryScope.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/VMEntryScope.cpp | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/Source/JavaScriptCore/runtime/VMEntryScope.cpp b/Source/JavaScriptCore/runtime/VMEntryScope.cpp index 8241dece2..47782ce3b 100644 --- a/Source/JavaScriptCore/runtime/VMEntryScope.cpp +++ b/Source/JavaScriptCore/runtime/VMEntryScope.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Apple Inc. All rights reserved. + * Copyright (C) 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 @@ -27,55 +27,69 @@ #include "VMEntryScope.h" #include "Debugger.h" -#include "Options.h" -#include "SamplingProfiler.h" #include "VM.h" -#include "Watchdog.h" #include <wtf/StackBounds.h> namespace JSC { VMEntryScope::VMEntryScope(VM& vm, JSGlobalObject* globalObject) : m_vm(vm) + , m_stack(wtfThreadData().stack()) , m_globalObject(globalObject) + , m_prev(vm.entryScope) + , m_prevStackLimit(vm.stackLimit()) + , m_recompilationNeeded(false) { - ASSERT(wtfThreadData().stack().isGrowingDownward()); if (!vm.entryScope) { +#if ENABLE(ASSEMBLER) + if (ExecutableAllocator::underMemoryPressure()) + vm.heap.deleteAllCompiledCode(); +#endif vm.entryScope = this; // Reset the date cache between JS invocations to force the VM to - // observe time zone changes. + // observe time xone changes. vm.resetDateCache(); - - if (vm.watchdog()) - vm.watchdog()->enteredVM(); - -#if ENABLE(SAMPLING_PROFILER) - if (SamplingProfiler* samplingProfiler = vm.samplingProfiler()) - samplingProfiler->noticeVMEntry(); -#endif } + // Clear the exception stack between entries + vm.clearExceptionStack(); - vm.clearLastException(); + void* limit = m_stack.recursionLimit(requiredCapacity()); + vm.setStackLimit(limit); } -void VMEntryScope::addDidPopListener(std::function<void ()> listener) +VMEntryScope::~VMEntryScope() { - m_didPopListeners.append(listener); + m_vm.entryScope = m_prev; + m_vm.setStackLimit(m_prevStackLimit); + + if (m_recompilationNeeded) { + if (m_vm.entryScope) + m_vm.entryScope->setRecompilationNeeded(true); + else { + if (Debugger* debugger = m_globalObject->debugger()) + debugger->recompileAllJSFunctions(&m_vm); + } + } } -VMEntryScope::~VMEntryScope() +size_t VMEntryScope::requiredCapacity() const { - if (m_vm.entryScope != this) - return; - - if (m_vm.watchdog()) - m_vm.watchdog()->exitedVM(); + Interpreter* interpreter = m_vm.interpreter; - m_vm.entryScope = nullptr; + // We require a smaller stack budget for the error stack. This is to allow + // some minimal JS execution to proceed and do the work of throwing a stack + // overflow error if needed. In contrast, arbitrary JS code will require the + // more generous stack budget in order to proceed. + // + // These sizes were derived from the stack usage of a number of sites when + // layout occurs when we've already consumed most of the C stack. + const size_t requiredStack = 128 * KB; + const size_t errorModeRequiredStack = 64 * KB; - for (auto& listener : m_didPopListeners) - listener(); + size_t requiredCapacity = interpreter->isInErrorHandlingMode() ? errorModeRequiredStack : requiredStack; + RELEASE_ASSERT(m_stack.size() >= requiredCapacity); + return requiredCapacity; } } // namespace JSC |