Commit 38bea920 authored by ggaren@apple.com's avatar ggaren@apple.com

JavaScriptCore:

2008-06-02  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Darin Adler.
        
        Fixed ASSERT due to execution continuing after an exception is thrown
        during array sort.

        * kjs/array_instance.cpp:
        (KJS::AVLTreeAbstractorForArrayCompare::compare_key_key): Don't call the
        custom comparator function if an exception has been thrown. Just return
        1 for everything, so the sort completes quickly. (The result will be
        thrown away.)

LayoutTests:

2008-06-02  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Darin Adler.
        
        Test for an exception thrown from an array sort comparator function.

        * fast/js/throw-from-array-sort-expected.txt: Added.
        * fast/js/throw-from-array-sort.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34302 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 12322c24
2008-06-02 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
Fixed ASSERT due to execution continuing after an exception is thrown
during array sort.
* kjs/array_instance.cpp:
(KJS::AVLTreeAbstractorForArrayCompare::compare_key_key): Don't call the
custom comparator function if an exception has been thrown. Just return
1 for everything, so the sort completes quickly. (The result will be
thrown away.)
2008-05-30 Timothy Hatcher <timothy@apple.com>
Made the starting line number of scripts be 1-based throughout the engine.
......
......@@ -540,6 +540,9 @@ struct AVLTreeAbstractorForArrayCompare {
ASSERT(!va->isUndefined());
ASSERT(!vb->isUndefined());
if (m_exec->hadException())
return 1;
List arguments;
arguments.append(va);
arguments.append(vb);
......
2008-06-02 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
Test for an exception thrown from an array sort comparator function.
* fast/js/throw-from-array-sort-expected.txt: Added.
* fast/js/throw-from-array-sort.html: Added.
2008-06-02 Simon Pieters <zcorpan@hotmail.com>
Reviewed and landed by Alexey.
This test verifies that an exception thrown during array sort immediately ends execution.
If the test passes, you'll see a pass message below.
PASS
<p>This test verifies that an exception thrown during array sort immediately ends execution.</p>
<p>If the test passes, you'll see a pass message below.</p>
<pre id="console">FAIL: Exception did not propogate from array sort.</pre>
<script>
function log(s)
{
document.getElementById("console").innerHTML = s + "\n";
}
if (window.layoutTestController)
layoutTestController.dumpAsText();
var passed = true;
var array = [ 1, 2, 3 ];
var sortFunction = (function () {
var alreadyCalled = false;
return function (a, b)
{
if (alreadyCalled)
passed = false;
alreadyCalled = true;
throw 'threw';
};
})();
try {
array.sort(sortFunction);
} catch(e) {
var result = passed ? "PASS"
: "FAIL: sort function was called after an exception was thrown"
log (result);
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment