Diff
Modified: trunk/JSTests/ChangeLog (238161 => 238162)
--- trunk/JSTests/ChangeLog 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/JSTests/ChangeLog 2018-11-14 04:57:33 UTC (rev 238162)
@@ -1,3 +1,15 @@
+2018-11-13 Saam Barati <[email protected]>
+
+ TypeProfileLog::processLogEntries should stash away any pending exceptions and re-apply them to the VM
+ https://bugs.webkit.org/show_bug.cgi?id=191600
+
+ Reviewed by Mark Lam.
+
+ * stress/type-profiler-log-should-defer-pending-exceptions.js: Added.
+ (foo):
+ (test):
+ (bar):
+
2018-11-13 Ryan Haddad <[email protected]>
Unreviewed, rolling out r238132.
Added: trunk/JSTests/stress/type-profiler-log-should-defer-pending-exceptions.js (0 => 238162)
--- trunk/JSTests/stress/type-profiler-log-should-defer-pending-exceptions.js (rev 0)
+++ trunk/JSTests/stress/type-profiler-log-should-defer-pending-exceptions.js 2018-11-14 04:57:33 UTC (rev 238162)
@@ -0,0 +1,26 @@
+//@ runDefault("--thresholdForOptimizeAfterWarmUp=0", "--useTypeProfiler=true")
+
+function foo() {
+ try {
+ throw 42;
+ } catch(e) {
+ if (e !== 42)
+ throw new Error("Bad!")
+ }
+}
+
+function test(_a) {
+ if (_a === 0) {
+ foo();
+ }
+}
+
+function bar() {
+ test(Intl.NumberFormat());
+ test(Intl.NumberFormat());
+ test(0);
+}
+
+for (let i=0; i<200; i++) {
+ bar()
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (238161 => 238162)
--- trunk/Source/_javascript_Core/ChangeLog 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-11-14 04:57:33 UTC (rev 238162)
@@ -1,3 +1,39 @@
+2018-11-13 Saam Barati <[email protected]>
+
+ TypeProfileLog::processLogEntries should stash away any pending exceptions and re-apply them to the VM
+ https://bugs.webkit.org/show_bug.cgi?id=191600
+
+ Reviewed by Mark Lam.
+
+ processLogEntries will call into calculatedClassName, which will clear
+ any exceptions it encounters (it assumes that they're stack overflow exceptions).
+ However, this code may be called when an exception is already pending on the
+ VM (e.g, when we throw an exception in the DFG, we compile an OSR exit
+ offramp, which may compile a baseline codeblock, which will process
+ the type profiler log). To get around this, processLogEntires should stash
+ away and re-apply any pending exceptions.
+
+ * dfg/DFGDriver.cpp:
+ (JSC::DFG::compileImpl):
+ * dfg/DFGOperations.cpp:
+ * inspector/agents/InspectorRuntimeAgent.cpp:
+ (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
+ * jit/JIT.cpp:
+ (JSC::JIT::doMainThreadPreparationBeforeCompile):
+ * jit/JITOperations.cpp:
+ * runtime/CommonSlowPaths.cpp:
+ (JSC::SLOW_PATH_DECL):
+ * runtime/TypeProfilerLog.cpp:
+ (JSC::TypeProfilerLog::processLogEntries):
+ * runtime/TypeProfilerLog.h:
+ * runtime/VM.cpp:
+ (JSC::VM::dumpTypeProfilerData):
+ * runtime/VM.h:
+ (JSC::VM::DeferExceptionScope::DeferExceptionScope):
+ * tools/JSDollarVM.cpp:
+ (JSC::functionFindTypeForExpression):
+ (JSC::functionReturnTypeFor):
+
2018-11-13 Ryan Haddad <[email protected]>
Unreviewed, rolling out r238132.
Modified: trunk/Source/_javascript_Core/dfg/DFGDriver.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -97,7 +97,7 @@
vm.getCTIStub(linkPolymorphicCallThunkGenerator);
if (vm.typeProfiler())
- vm.typeProfilerLog()->processLogEntries("Preparing for DFG compilation."_s);
+ vm.typeProfilerLog()->processLogEntries(vm, "Preparing for DFG compilation."_s);
Ref<Plan> plan = adoptRef(
*new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues));
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -2705,7 +2705,7 @@
VM& vm = exec->vm();
NativeCallFrameTracer tracer(&vm, exec);
- vm.typeProfilerLog()->processLogEntries("Log Full, called from inside DFG."_s);
+ vm.typeProfilerLog()->processLogEntries(vm, "Log Full, called from inside DFG."_s);
}
EncodedJSValue JIT_OPERATION operationResolveScopeForHoistingFuncDeclInEval(ExecState* exec, JSScope* scope, UniquedStringImpl* impl)
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -273,7 +273,7 @@
}
MonotonicTime start = MonotonicTime::now();
- m_vm.typeProfilerLog()->processLogEntries("User Query"_s);
+ m_vm.typeProfilerLog()->processLogEntries(m_vm, "User Query"_s);
for (size_t i = 0; i < locations.length(); i++) {
RefPtr<JSON::Value> value = locations.get(i);
Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/jit/JIT.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -948,7 +948,7 @@
{
// This ensures that we have the most up to date type information when performing typecheck optimizations for op_profile_type.
if (m_vm->typeProfiler())
- m_vm->typeProfilerLog()->processLogEntries("Preparing for JIT compilation."_s);
+ m_vm->typeProfilerLog()->processLogEntries(*m_vm, "Preparing for JIT compilation."_s);
}
unsigned JIT::frameRegisterCountFor(CodeBlock* codeBlock)
Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/jit/JITOperations.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -2874,7 +2874,7 @@
{
VM& vm = exec->vm();
NativeCallFrameTracer tracer(&vm, exec);
- vm.typeProfilerLog()->processLogEntries("Log Full, called from inside baseline JIT"_s);
+ vm.typeProfilerLog()->processLogEntries(vm, "Log Full, called from inside baseline JIT"_s);
}
void JIT_OPERATION operationProcessShadowChickenLog(ExecState* exec)
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -963,7 +963,7 @@
SLOW_PATH_DECL(slow_path_profile_type_clear_log)
{
BEGIN();
- vm.typeProfilerLog()->processLogEntries("LLInt log full."_s);
+ vm.typeProfilerLog()->processLogEntries(vm, "LLInt log full."_s);
END();
}
Modified: trunk/Source/_javascript_Core/runtime/TypeProfilerLog.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/runtime/TypeProfilerLog.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/runtime/TypeProfilerLog.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -55,8 +55,15 @@
delete[] m_logStartPtr;
}
-void TypeProfilerLog::processLogEntries(const String& reason)
+void TypeProfilerLog::processLogEntries(VM& vm, const String& reason)
{
+ // We need to do this because this code will call into calculatedDisplayName.
+ // calculatedDisplayName will clear any exception it sees (because it thinks
+ // it's a stack overflow). We may be called when an exception was already
+ // thrown, so we don't want calcualtedDisplayName to clear that exception that
+ // was thrown before we even got here.
+ VM::DeferExceptionScope deferExceptionScope(vm);
+
MonotonicTime before { };
if (TypeProfilerLogInternal::verbose) {
dataLog("Process caller:'", reason, "'");
Modified: trunk/Source/_javascript_Core/runtime/TypeProfilerLog.h (238161 => 238162)
--- trunk/Source/_javascript_Core/runtime/TypeProfilerLog.h 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/runtime/TypeProfilerLog.h 2018-11-14 04:57:33 UTC (rev 238162)
@@ -56,7 +56,7 @@
TypeProfilerLog(VM&);
~TypeProfilerLog();
- JS_EXPORT_PRIVATE void processLogEntries(const String&);
+ JS_EXPORT_PRIVATE void processLogEntries(VM&, const String&);
LogEntry* logEndPtr() const { return m_logEndPtr; }
void visit(SlotVisitor&);
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -1116,7 +1116,7 @@
if (!typeProfiler())
return;
- typeProfilerLog()->processLogEntries("VM Dump Types"_s);
+ typeProfilerLog()->processLogEntries(*this, "VM Dump Types"_s);
typeProfiler()->dumpTypeProfilerData(*this);
}
Modified: trunk/Source/_javascript_Core/runtime/VM.h (238161 => 238162)
--- trunk/Source/_javascript_Core/runtime/VM.h 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2018-11-14 04:57:33 UTC (rev 238162)
@@ -63,6 +63,7 @@
#include <wtf/Gigacage.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/SetForScope.h>
#include <wtf/StackBounds.h>
#include <wtf/StackPointer.h>
#include <wtf/Stopwatch.h>
@@ -893,6 +894,19 @@
JS_EXPORT_PRIVATE void setRunLoop(CFRunLoopRef);
#endif // USE(CF)
+ class DeferExceptionScope {
+ public:
+ DeferExceptionScope(VM& vm)
+ : m_savedException(vm.m_exception, nullptr)
+ , m_savedLastException(vm.m_lastException, nullptr)
+ {
+ }
+
+ private:
+ SetForScope<Exception*> m_savedException;
+ SetForScope<Exception*> m_savedLastException;
+ };
+
private:
friend class LLIntOffsetsExtractor;
Modified: trunk/Source/_javascript_Core/tools/JSDollarVM.cpp (238161 => 238162)
--- trunk/Source/_javascript_Core/tools/JSDollarVM.cpp 2018-11-14 04:52:22 UTC (rev 238161)
+++ trunk/Source/_javascript_Core/tools/JSDollarVM.cpp 2018-11-14 04:57:33 UTC (rev 238162)
@@ -1946,7 +1946,7 @@
{
VM& vm = exec->vm();
RELEASE_ASSERT(vm.typeProfiler());
- vm.typeProfilerLog()->processLogEntries("jsc Testing API: functionFindTypeForExpression"_s);
+ vm.typeProfilerLog()->processLogEntries(vm, "jsc Testing API: functionFindTypeForExpression"_s);
JSValue functionValue = exec->argument(0);
RELEASE_ASSERT(functionValue.isFunction(vm));
@@ -1965,7 +1965,7 @@
{
VM& vm = exec->vm();
RELEASE_ASSERT(vm.typeProfiler());
- vm.typeProfilerLog()->processLogEntries("jsc Testing API: functionReturnTypeFor"_s);
+ vm.typeProfilerLog()->processLogEntries(vm, "jsc Testing API: functionReturnTypeFor"_s);
JSValue functionValue = exec->argument(0);
RELEASE_ASSERT(functionValue.isFunction(vm));