Index: test/mjsunit/simd/deopt.js |
diff --git a/test/mjsunit/regress/regress-1118.js b/test/mjsunit/simd/deopt.js |
similarity index 60% |
copy from test/mjsunit/regress/regress-1118.js |
copy to test/mjsunit/simd/deopt.js |
index 4fd23456bea5aca9ce23a6d2fc06a2bf58bfc254..66465c2eb4020fe03fc90de39badfb2b357b9605 100644 |
--- a/test/mjsunit/regress/regress-1118.js |
+++ b/test/mjsunit/simd/deopt.js |
@@ -25,42 +25,54 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Flags: --allow-natives-syntax |
+// Flags: --simd_object --allow-natives-syntax |
-// An exception thrown in a function optimized by on-stack replacement (OSR) |
-// should be able to construct a receiver from all optimized stack frames. |
+function testdeopt(a, b) { |
+ var a4 = float32x4(1.0, -2.0, 3.0, -4.0); |
+ var b4 = SIMD.float32x4.abs(a4); |
-function A() { } |
-A.prototype.f = function() { } |
+ if (a > 0) { |
+ a = 0; |
+ } else { |
+ a += b; //deopt |
+ } |
-function B() { } |
+ assertEquals(1.0, b4.x); |
+ assertEquals(2.0, b4.y); |
+ assertEquals(3.0, b4.z); |
+ assertEquals(4.0, b4.w); |
+} |
-var o = new A(); |
+testdeopt(1, 1); |
+testdeopt(1, 1); |
+%OptimizeFunctionOnNextCall(testdeopt); |
+testdeopt(0, 1); |
-// This function throws if o does not have an f property, and should not be |
-// inlined. |
-function g() { try { return o.f(); } finally { }} |
+function testdeopt2() { |
+ var a4 = float32x4(1.0, -1.0, 1.0, -1.0); |
+ var b4 = SIMD.float32x4.abs(a4); |
-// Optimization status (see runtime.cc): |
-// 1 - yes, 2 - no, 3 - always, 4 - never. |
+ assertEquals(1.0, b4.x); |
+ assertEquals(1.0, b4.y); |
+ assertEquals(1.0, b4.z); |
+ assertEquals(1.0, b4.w); |
-// This function should be optimized via OSR. |
-function h() { |
- var optstatus = %GetOptimizationStatus(h); |
- if (optstatus == 4) { |
- // Optimizations are globally disabled; just run once. |
- g(); |
- } else { |
- // Run for a bit as long as h is unoptimized. |
- if (%GetOptimizationStatus(h) != 4) { |
- while (%GetOptimizationCount(h) == 0) { |
- for (var j = 0; j < 100; j++) g(); |
- } |
- } |
- g(); |
- } |
+ var new_a4 = new float32x4(1.0, -1.0, 1.0, -1.0); |
+ var new_b4 = SIMD.float32x4.abs(new_a4); |
+ |
+ assertEquals(1.0, new_b4.x); |
+ assertEquals(1.0, new_b4.y); |
+ assertEquals(1.0, new_b4.z); |
+ assertEquals(1.0, new_b4.w); |
+ |
+ // Verifying deoptimization |
+ assertEquals(1.0, b4.x); |
+ assertEquals(1.0, b4.y); |
+ assertEquals(1.0, b4.z); |
+ assertEquals(1.0, b4.w); |
} |
-h(); |
-o = new B(); |
-assertThrows("h()"); |
+testdeopt2(); |
+testdeopt2(); |
+%OptimizeFunctionOnNextCall(testdeopt2); |
+testdeopt2(); |