Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: test/mjsunit/regress/regress-crbug-323942.js

Issue 95123003: Fix bug in inlining Function.apply. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698