Title: [202838] trunk/Source/_javascript_Core
- Revision
- 202838
- Author
- [email protected]
- Date
- 2016-07-05 16:09:51 -0700 (Tue, 05 Jul 2016)
Log Message
Crash @ bankofamerica.com, University of Vienna
https://bugs.webkit.org/show_bug.cgi?id=159439
Reviewed by Saam Barati.
* ftl/FTLLink.cpp:
(JSC::FTL::link): Do check for stack overflow in the arity mismatch thunk
because it can happen. Don't store a CallSiteIndex because we haven't
stored a CodeBlock yet, and our stack frame is not fully constructed,
so it would be an error for any client to try to load this value (and
operationCallArityCheck does not load this value).
* tests/stress/arity-check-ftl-throw.js: Added. New test case for stressing
a stack overflow with arity mismatch. Sadly, after hours of fiddling, I
can't seem to get this to fail in trunk. Still, it's good to have some
more testing in this area.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (202837 => 202838)
--- trunk/Source/_javascript_Core/ChangeLog 2016-07-05 22:27:58 UTC (rev 202837)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-07-05 23:09:51 UTC (rev 202838)
@@ -1,3 +1,22 @@
+2016-07-05 Geoffrey Garen <[email protected]>
+
+ Crash @ bankofamerica.com, University of Vienna
+ https://bugs.webkit.org/show_bug.cgi?id=159439
+
+ Reviewed by Saam Barati.
+
+ * ftl/FTLLink.cpp:
+ (JSC::FTL::link): Do check for stack overflow in the arity mismatch thunk
+ because it can happen. Don't store a CallSiteIndex because we haven't
+ stored a CodeBlock yet, and our stack frame is not fully constructed,
+ so it would be an error for any client to try to load this value (and
+ operationCallArityCheck does not load this value).
+
+ * tests/stress/arity-check-ftl-throw.js: Added. New test case for stressing
+ a stack overflow with arity mismatch. Sadly, after hours of fiddling, I
+ can't seem to get this to fail in trunk. Still, it's good to have some
+ more testing in this area.
+
2016-07-05 Benjamin Poulain <[email protected]>
[JSC] The prototype cycle checks throws the wrong error type
Modified: trunk/Source/_javascript_Core/ftl/FTLLink.cpp (202837 => 202838)
--- trunk/Source/_javascript_Core/ftl/FTLLink.cpp 2016-07-05 22:27:58 UTC (rev 202837)
+++ trunk/Source/_javascript_Core/ftl/FTLLink.cpp 2016-07-05 23:09:51 UTC (rev 202838)
@@ -137,19 +137,22 @@
CCallHelpers::TrustedImm32(codeBlock->numParameters())));
jit.emitFunctionPrologue();
jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
- jit.store32(
- CCallHelpers::TrustedImm32(CallSiteIndex(0).bits()),
- CCallHelpers::tagFor(JSStack::ArgumentCount));
jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame);
CCallHelpers::Call callArityCheck = jit.call();
+
+ auto noException = jit.branch32(CCallHelpers::AboveOrEqual, GPRInfo::returnValueGPR, CCallHelpers::TrustedImm32(0));
+ jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer();
+ jit.move(CCallHelpers::TrustedImmPtr(jit.vm()), GPRInfo::argumentGPR0);
+ jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
+ CCallHelpers::Call callLookupExceptionHandlerFromCallerFrame = jit.call();
+ jit.jumpToExceptionHandler();
+ noException.link(&jit);
+
#if !ASSERT_DISABLED
- // FIXME: need to make this call register with exception handling somehow. This is
- // part of a bigger problem: FTL should be able to handle exceptions.
- // https://bugs.webkit.org/show_bug.cgi?id=113622
- // Until then, use a JIT ASSERT.
jit.load64(vm.addressOfException(), GPRInfo::regT1);
jit.jitAssertIsNull(GPRInfo::regT1);
#endif
+
jit.move(GPRInfo::returnValueGPR, GPRInfo::argumentGPR0);
jit.emitFunctionEpilogue();
mainPathJumps.append(jit.branchTest32(CCallHelpers::Zero, GPRInfo::argumentGPR0));
@@ -164,6 +167,7 @@
return;
}
linkBuffer->link(callArityCheck, codeBlock->m_isConstructor ? operationConstructArityCheck : operationCallArityCheck);
+ linkBuffer->link(callLookupExceptionHandlerFromCallerFrame, lookupExceptionHandlerFromCallerFrame);
linkBuffer->link(callArityFixup, FunctionPtr((vm.getCTIStub(arityFixupGenerator)).code().executableAddress()));
linkBuffer->link(mainPathJumps, CodeLocationLabel(bitwise_cast<void*>(state.generatedFunction)));
Added: trunk/Source/_javascript_Core/tests/stress/arity-check-ftl-throw.js (0 => 202838)
--- trunk/Source/_javascript_Core/tests/stress/arity-check-ftl-throw.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/arity-check-ftl-throw.js 2016-07-05 23:09:51 UTC (rev 202838)
@@ -0,0 +1,35 @@
+// Require lots of arguments so that arity fixup will need a lot of stack, making
+// it prone to stack overflow.
+var script = "";
+for (var i = 0; i < 128; ++i)
+ script += "dummy, "
+script += "dummy";
+var g = new Function(script, "return arguments;"); // Ensure that arguments are observed.
+
+function f(recursionCount)
+{
+ if (!recursionCount)
+ return;
+
+ // Use too few arguments to force arity fixup.
+ g();
+
+ f(--recursionCount);
+}
+
+noInline(g);
+noInline(f);
+
+// Ensure that f and g get optimized.
+for (var i = 0; i < 1000000; ++i) {
+ // Recurse once to ensure profiling along all control flow paths.
+ f(1);
+}
+
+try {
+ // Recurse enough times to trigger a stack overflow exception.
+ f(1000000);
+} catch(e) {
+ if (! (e instanceof RangeError))
+ throw "bad value for e";
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes