Index: test/mjsunit/regress/regress-crbug-323942.js |
diff --git a/test/mjsunit/compiler/multiply-sub.js b/test/mjsunit/regress/regress-crbug-323942.js |
similarity index 69% |
copy from test/mjsunit/compiler/multiply-sub.js |
copy to test/mjsunit/regress/regress-crbug-323942.js |
index 4793181d47a2b4a2b2390f5049758e651ef1ec1c..15af494b0fda0ab457f15a15e5ba3cf2070db81f 100644 |
--- a/test/mjsunit/compiler/multiply-sub.js |
+++ b/test/mjsunit/regress/regress-crbug-323942.js |
@@ -26,31 +26,32 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
// Flags: --allow-natives-syntax |
-// Test expressions that can be computed with a multiply-add instruction. |
-function f(a, b, c) { |
- return a - b * c; |
-} |
+"use strict"; |
-function g(a, b, c) { |
- return a * b - c; |
-} |
+// Function is defined on the prototype chain. |
+var holder = { f: function() { return 42; } }; |
+var receiver = { }; |
+receiver.__proto__ = { }; |
+receiver.__proto__.__proto__ = holder; |
-function h(a, b, c, d) { |
- return a * b - c * d; |
-} |
+// Inline two levels. |
+function h(o) { return o.f.apply(this, arguments); } |
+function g(o) { return h(o); } |
-assertEquals(-5.41, f(1.1, 2.1, 3.1)); |
-assertEquals(-5.41, f(1.1, 2.1, 3.1)); |
-%OptimizeFunctionOnNextCall(f); |
-assertEquals(-5.41, f(1.1, 2.1, 3.1)); |
+// Collect type information for apply call. |
+assertEquals(42, g(receiver)); |
+assertEquals(42, g(receiver)); |
-assertEquals(8.36, g(2.2, 3.3, -1.1)); |
-assertEquals(8.36, g(2.2, 3.3, -1.1)); |
+// Sneakily remove the function from the prototype chain. |
+// The receiver map does not change. |
+receiver.__proto__.__proto__ = {}; |
+ |
+// Lookup of o.f during graph creation fails. |
%OptimizeFunctionOnNextCall(g); |
-assertEquals(8.36, g(2.2, 3.3, -1.1)); |
-assertEquals(-1.5, h(1.5, 3.0, 12, 0.5)); |
-assertEquals(-1.5, h(1.5, 3.0, 12, 0.5)); |
-%OptimizeFunctionOnNextCall(h); |
-assertEquals(-1.5, h(1.5, 3.0, 12, 0.5)); |
+assertThrows(function() { g(receiver); }); |
+ |
+// Put function back. |
+receiver.__proto__.__proto__ = holder; |
+assertEquals(42, g(receiver)); |