[pypy-svn] r20918 - in pypy/dist/pypy/translator/js: src test

ericvrp at codespeak.net ericvrp at codespeak.net
Fri Dec 9 11:10:25 CET 2005


Author: ericvrp
Date: Fri Dec  9 11:10:23 2005
New Revision: 20918

Modified:
   pypy/dist/pypy/translator/js/src/ll_stackless.js
   pypy/dist/pypy/translator/js/src/stack.js
   pypy/dist/pypy/translator/js/test/browsertest.py
   pypy/dist/pypy/translator/js/test/test_genllvm1.py
   pypy/dist/pypy/translator/js/test/test_stackless.py
Log:
Fixes to get things working in Safari
(which is the one with the most limited recusion limit (100)


Modified: pypy/dist/pypy/translator/js/src/ll_stackless.js
==============================================================================
--- pypy/dist/pypy/translator/js/src/ll_stackless.js	(original)
+++ pypy/dist/pypy/translator/js/src/ll_stackless.js	Fri Dec  9 11:10:23 2005
@@ -7,6 +7,7 @@
 var slp_timeout            = false;
 var slp_start_time         = undefined;
 var slp_stack_depth        = 0;
+var slp_max_stack_depth    = 75;    // XXX make this browser dependent (75:Safari, 750:Firefox/Spidermonkey, more:IE)
 
 function function_name(func) {
     var s = func.toString().split("\n");
@@ -36,7 +37,7 @@
 //
 
 function ll_stack_too_big() {
-    var result = slp_stack_depth > 500;   // Firefox has a recursion limit of 1000 (others allow more)
+    var result = slp_stack_depth > slp_max_stack_depth;   // Firefox has a recursion limit of 1000 (others allow more)
     LOG("ll_stack_to_big result=" + result);
 
     if (!result && in_browser && false) {
@@ -166,6 +167,7 @@
         }
     }
     log("REALLY FINISHED");
+    handle_result(slp_return_value);
 }
 
 // 

Modified: pypy/dist/pypy/translator/js/src/stack.js
==============================================================================
--- pypy/dist/pypy/translator/js/src/stack.js	(original)
+++ pypy/dist/pypy/translator/js/src/stack.js	Fri Dec  9 11:10:23 2005
@@ -13,3 +13,8 @@
     return false;
 }
 ll_stack_too_big__ = ll_stack_too_big;
+
+function ll_stack_unwind() {
+    throw "Recursion limit exceeded";
+}
+ll_stack_unwind__ = ll_stack_unwind;

Modified: pypy/dist/pypy/translator/js/test/browsertest.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/browsertest.py	(original)
+++ pypy/dist/pypy/translator/js/test/browsertest.py	Fri Dec  9 11:10:23 2005
@@ -30,12 +30,16 @@
         }
     }
 
-    if (result != undefined || !in_browser) {  // if no timeout (i.e. not long running)
-        var resultform = document.forms['resultform'];
-        resultform.result.value = result;
-        resultform.submit();
+    if (result != undefined || !in_browser) {  // if valid result (no timeout)
+        handle_result(result);
     }
 };
+
+function handle_result(result) {
+    var resultform = document.forms['resultform'];
+    resultform.result.value = result;
+    resultform.submit();
+};
 </script>
 </head>
 <body onload="runTest()">

Modified: pypy/dist/pypy/translator/js/test/test_genllvm1.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_genllvm1.py	(original)
+++ pypy/dist/pypy/translator/js/test/test_genllvm1.py	Fri Dec  9 11:10:23 2005
@@ -28,7 +28,7 @@
 
     def test_ackermann(self):
         f = compile_function(llvmsnippet.ackermann, [int, int])
-        for i in range(7):  #>7 js error: too much recursion?!?
+        for i in range(4):  # (otherwise too much recursion) max 4 in Safari, max 7 in Firefox, IE allows more recursion
             assert f(0, i) == i + 1
             assert f(1, i) == i + 2
             assert f(2, i) == 2 * i + 3

Modified: pypy/dist/pypy/translator/js/test/test_stackless.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_stackless.py	(original)
+++ pypy/dist/pypy/translator/js/test/test_stackless.py	Fri Dec  9 11:10:23 2005
@@ -107,7 +107,7 @@
     def fn():
         return f(0)
     data = wrap_stackless_function(fn)
-    assert int(data.strip()) == 494
+    assert int(data.strip()) > 50   #conservative estimate because the value is browser dependent
 
 
 def test_stack_unwind():



More information about the Pypy-commit mailing list