2008-05-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver.
- fixed <rdar://problem/
5972943> REGRESSION(r33979): Flash clips do not play on cnn.com
Finally blocks could clobber registers that had to remain live
until they returned. This patch takes a conservative approach and
makes sure that finally blocks do not reuse any registers that
were previously allocated for the function. In the future this
could probably be tightened up to be less profligate with the
register allocation.
* VM/CodeGenerator.cpp:
(KJS::CodeGenerator::highestUsedRegister):
* VM/CodeGenerator.h:
* kjs/nodes.cpp:
(KJS::TryNode::emitCode):
LayoutTests:
2008-05-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver. Test by Geoff Garen.
- fixed <rdar://problem/
5972943> REGRESSION(r33979): Flash clips do not play on cnn.com
* fast/js/finally-codegen-failure-expected.txt: Added.
* fast/js/finally-codegen-failure.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34250
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-05-29 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Oliver.
+
+ - fixed <rdar://problem/5972943> REGRESSION(r33979): Flash clips do not play on cnn.com
+
+ Finally blocks could clobber registers that had to remain live
+ until they returned. This patch takes a conservative approach and
+ makes sure that finally blocks do not reuse any registers that
+ were previously allocated for the function. In the future this
+ could probably be tightened up to be less profligate with the
+ register allocation.
+
+ * VM/CodeGenerator.cpp:
+ (KJS::CodeGenerator::highestUsedRegister):
+ * VM/CodeGenerator.h:
+ * kjs/nodes.cpp:
+ (KJS::TryNode::emitCode):
+
2008-05-29 Steve Falkenburg <sfalken@apple.com>
Build fix.
return &m_temporaries.last();
}
+
+RegisterID* CodeGenerator::highestUsedRegister()
+{
+ while (m_temporaries.size() < static_cast<unsigned>(m_codeBlock->numTemporaries))
+ m_temporaries.append(m_temporaries.size());
+ return &m_temporaries.last();
+}
+
PassRefPtr<LabelID> CodeGenerator::newLabel()
{
// Reclaim free label IDs.
// the next instruction may overwrite it.
RegisterID* newTemporary();
+ RegisterID* highestUsedRegister();
+
// The same as newTemporary(), but this function returns "suggestion" if
// "suggestion" is a temporary. This function is helpful in situations
// where you've put "suggestion" in a RefPtr, but you'd like to allow
if (m_finallyBlock) {
generator.popFinallyContext();
+ // there may be important registers live at the time we jump
+ // to a finally block (such as for a return or throw) so we
+ // ref the highest register ever used as a conservative
+ // approach to not clobbering anything important
+ RefPtr<RegisterID> highestUsedRegister = generator.highestUsedRegister();
RefPtr<LabelID> finallyEndLabel = generator.newLabel();
generator.emitJumpSubroutine(finallyReturnAddr.get(), finallyStart.get());
generator.emitJump(finallyEndLabel.get());
+2008-05-29 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Oliver. Test by Geoff Garen.
+
+ - fixed <rdar://problem/5972943> REGRESSION(r33979): Flash clips do not play on cnn.com
+
+ * fast/js/finally-codegen-failure-expected.txt: Added.
+ * fast/js/finally-codegen-failure.html: Added.
+
2008-05-28 Justin Garcia <justin.garcia@apple.com>
Reviewed by Eric.
--- /dev/null
+This page tests a codegen bug with finally blocks. If the test passes, you'll see a PASS message below.
+
+PASS
+
--- /dev/null
+<p>This page tests a codegen bug with finally blocks. If the test passes, you'll
+see a PASS message below.</p>
+
+<pre id="console"></pre>
+
+<script>
+function log(s)
+{
+ document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
+}
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+a = {
+ f: function() { return "PASS"; }
+};
+
+a.f.toString = function() { return "FAIL"; };
+
+function f() {
+ try {
+ a.f();
+ a.f();
+ return a.f();
+ } finally {
+ a.f();
+ }
+}
+log(f())
+</script>