summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/VMEntryScope.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/VMEntryScope.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/runtime/VMEntryScope.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/VMEntryScope.cpp71
1 files changed, 30 insertions, 41 deletions
diff --git a/Source/JavaScriptCore/runtime/VMEntryScope.cpp b/Source/JavaScriptCore/runtime/VMEntryScope.cpp
index 47782ce3b..e1e708ce0 100644
--- a/Source/JavaScriptCore/runtime/VMEntryScope.cpp
+++ b/Source/JavaScriptCore/runtime/VMEntryScope.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 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,70 +26,59 @@
#include "config.h"
#include "VMEntryScope.h"
-#include "Debugger.h"
+#include "Options.h"
+#include "SamplingProfiler.h"
#include "VM.h"
+#include "Watchdog.h"
#include <wtf/StackBounds.h>
+#include <wtf/SystemTracing.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 xone changes.
+ // observe time zone changes.
vm.resetDateCache();
+
+ if (vm.watchdog())
+ vm.watchdog()->enteredVM();
+
+#if ENABLE(SAMPLING_PROFILER)
+ if (SamplingProfiler* samplingProfiler = vm.samplingProfiler())
+ samplingProfiler->noticeVMEntry();
+#endif
+ TracePoint(VMEntryScopeStart);
}
- // Clear the exception stack between entries
- vm.clearExceptionStack();
- void* limit = m_stack.recursionLimit(requiredCapacity());
- vm.setStackLimit(limit);
+ vm.clearLastException();
}
-VMEntryScope::~VMEntryScope()
+void VMEntryScope::addDidPopListener(std::function<void ()> 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);
- }
- }
+ m_didPopListeners.append(listener);
}
-size_t VMEntryScope::requiredCapacity() const
+VMEntryScope::~VMEntryScope()
{
- Interpreter* interpreter = m_vm.interpreter;
+ if (m_vm.entryScope != this)
+ return;
+
+ TracePoint(VMEntryScopeEnd);
+
+ if (m_vm.watchdog())
+ m_vm.watchdog()->exitedVM();
- // 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;
+ m_vm.entryScope = nullptr;
- size_t requiredCapacity = interpreter->isInErrorHandlingMode() ? errorModeRequiredStack : requiredStack;
- RELEASE_ASSERT(m_stack.size() >= requiredCapacity);
- return requiredCapacity;
+ for (auto& listener : m_didPopListeners)
+ listener();
}
} // namespace JSC